jira-importer opened a new issue, #1037:
URL: https://github.com/apache/httpcomponents-core/issues/1037

   **[Paul 
Thompson](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=pathompson)**
 opened 
**[HTTPCORE-517](https://issues.apache.org/jira/browse/HTTPCORE-517?redirect=false)**
 and commented
   
   Utilising a java security manager you're able to block certain socket 
connections from taking place. This can be useful to block outgoing connections 
for all components.
   
   ```java
   @Override
   public void checkConnect(String host, int port) {
       if(port != -1) {
           for (String bannedPerm : bannedSocketPerms) {
               if (host.equalsIgnoreCase(bannedPerm)) {
                   throw new new SecurityException();
               }
           }
       }
   }
   ```
   
   Unfortunately when doing this, the apache reactor shuts down. The call site 
is in the `DefaultConnectingIOReactor`. 
   
   ```java
   final boolean connected = socketChannel.connect(request.getRemoteAddress());
   ```
   
   this line is wrapped in a try/catch that catches an `IOException`. This 
means the `SecurityException` is propagated out, and is never offered to be 
caught (even with the `ExceptionHandler` that you can set. 
   
   It would be an improvement to be able to throw these types of exceptions and 
have the reactor continue on. It's very understandable for the 
`SecurityException` to be a transient error and as such shouldn't shut down the 
entire reactor by default.
   
   Either that, or one should be able to define a `handleRuntimeException` (as 
seen in the `BaseIOREactor`) in such a way that it would get the option to 
handle the exceptions that are thrown as part of the `processEvents` call in 
the `AbstractIOReactor`
   
   
   ---
   
   **Backported to:** 
[4.4.10](https://github.com/apache/httpcomponents-core/milestone/47?closed=1)
   
   1 votes, 6 watchers
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to