You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by GitBox <gi...@apache.org> on 2022/04/13 13:11:57 UTC

[GitHub] [wicket] try0 commented on pull request #510: [WICKET-6971] NullPointerException in ModificationWatcher

try0 commented on PR #510:
URL: https://github.com/apache/wicket/pull/510#issuecomment-1098033247

   Hi @martin-g .
   Thank you for your advice.
   
   >IMO catching Exception and logging it as a WARNING would be better.
   
   Right.
   I agree this opinion.
   
   But author of the Connections class also implement closeQuietly method.
   So I think it's better to keep the throw exceptions in close method.
   
   It appears that there are only two callers of the close method, closeQuietly and org.apache.wicket.core.util.resource.UrlResourceStream#lastModifiedTime().
   
   https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/core/util/resource/UrlResourceStream.java#L246
   
   And lastModifiedTime() logs exceptions and return null.
   https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/core/util/resource/UrlResourceStream.java#L227
   
   So,
   ```
   InputStream inputStream = connection.getInputStream();
   if (inputStream == null)
   {
   	throw new IOException("No stream.");
   }
   ```
   Is it better this way?
   NullPointerException can be avoided and the code to be changed is minimal.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org