This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpURLConnection getResponseCode throwing error  RSS feed

 
Darvesh Niz
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

We are trying to see why would a HttpURLConnection.getResponseCode() will throw a FileNotFound exception rather than checking it. We are calling a third party api url "https://somedomainhere/api/v1/discussion.json?Discussion.ForeignID=9f0fd31d92e5a8e0b279380578dcd188" and there are certain cases when the third party server will send us back a 404 response. But we are getting an exception right when check the getResponseCode(), why would it throw an exception. i have wrote a small program and debugged it and when i gave a bad url it worked fine and there was no error, but the error keeps on happening on our server and fill up the logs. Also whats more frustating is we are trying to suppress the log and i have put sufficient Exception block to catch the exception yet somehow the error gets printed in the logs. Below is my


any advice the error right when the check condition happens below is the stack trace
java.io.FileNotFoundException.https://xxx.com/api/v1/discussion.json?Discussion.ForeignID=c2b8546500508021f771bf3876466c36
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1624)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
at com.xxx.editorial.util.ConsumerCommentUtil.getVanillaUrl(ConsumerCommentUtil.java:120)
at com.xxx.editorial.util.ConsumerCommentUtil.getConsumerComments(ConsumerCommentUtil.java:60)
at com.xxx.editorial.tags.ConsumerCommentsTag.getBean(ConsumerCommentsTag.java:41)
at com.xxx.common.web.tags.ScopedBeanTag.setAttributeInScope(ScopedBeanTag.java:80)
at com.xxx.common.web.tags.ScopedBeanTag.doEndTag(ScopedBeanTag.java:44)
at freemarker.ext.jsp.TagTransformModel$TagWriter.endEvaluation(TagTransformModel.java:430)
at freemarker.ext.jsp.TagTransformModel$TagWriter.afterBody(TagTransformModel.java:406)
at freemarker.core.Environment.visit(Environment.java:312)
at freemarker.core.UnifiedCall.accept(UnifiedCall.java:130)
at freemarker.core.Environment.visit(Environment.java:221)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:221)
at freemarker.core.Environment.visit(Environment.java:310)
at freemarker.core.UnifiedCall.accept(UnifiedCall.java:130)
at freemarker.core.Environment.visit(Environment.java:221)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:221)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!