0

I'm debugging my java code but eclipse keeps stopping as if I have a breakpoint in the following code (the code is from java's HttpURLConnection, line 550):

@SuppressWarnings("deprecation")
    public long getHeaderFieldDate(String name, long Default) {
        String dateString = getHeaderField(name);
        try {
            if (dateString.indexOf("GMT") == -1) { // stops here
                dateString = dateString+" GMT";
            }
            return Date.parse(dateString);
        } catch (Exception e) {
        }
        return Default;
}

DateString is null.

Note I DID uncheck "stop at unchecked exceptions" in windows > preferences > java > debug but even so the problem persists.

agiro
  • 2,018
  • 2
  • 30
  • 62
  • Most likely `getHeaderField()` is returning NULL. What's the behavior of `getHeaderField()`? – thekenobe Sep 17 '18 at 18:23
  • yes that is the problem but it's a builtin class by java so I cannot change it. Another thing is that the exception is caught and I have no breakpoint. Why does the debugger stop there? – agiro Sep 17 '18 at 18:24
  • Give it a _clean and build_ and try again. – Roshana Pitigala Sep 17 '18 at 18:27
  • @RoshanaPitigala tried this https://stackoverflow.com/questions/6803322/how-to-achieve-that-eclipse-clean-and-build-aka-rebuild but no luck unfortunately. – agiro Sep 17 '18 at 18:31
  • show us the `getHeaderField()` method – Roshana Pitigala Sep 17 '18 at 18:33
  • It is a built-in java method with the link in the post. here's the link to java's source code: https://github.com/frohoff/jdk8u-jdk/blob/master/src/share/classes/java/net/HttpURLConnection.java#L89 – agiro Sep 17 '18 at 18:39
  • The code here should be running fine, since the thrown `NPE` is caught by the `catch` clause. Try cleaning, rebuilding or restarting Eclipse. – MC Emperor Sep 17 '18 at 19:05
  • 1
    Make sure in the [_Breakpoints_ view](https://help.eclipse.org/photon/topic/org.eclipse.jdt.doc.user/reference/views/breakpoints/ref-breakpoints_view.htm) all Java exception breakpoints are disabled. – howlger Sep 17 '18 at 19:05
  • @howlger might want to convert that to an answer because it did the trick. – agiro Sep 18 '18 at 07:38

1 Answers1

1

Make sure in the Breakpoints view all Java exception breakpoints are disabled.

howlger
  • 31,050
  • 11
  • 59
  • 99