title: unexpected behavior in java exception flow
body: <p>I have written following code snippet:-</p>
  
  <pre><code>public Collection&lt;?&gt; constructResponse (...........) throws RemoteException { 
  
    while (keyIterator.hasNext())
                  {
                      String keyValue = (String) keyIterator.next();
                      keyString = new StringBuilder(); // since multiple keys will be there in map need to ensure every time keyString and valueString is created
                      valueString = new StringBuilder();
                      keyString.append(keyValue + ";" + "name");
                      List&lt;CustomValuePOJO&gt; customPOJOlist = employeeValuesMap.get(keyValue );
                      for (CustomValuePOJO customPOJO : customPOJOlist )
                      {
                          if (protocol == null || protocol.equals(""))
                          {
                              valueString.append(rpNatPOJO.getDcnPort() + ":"+ rpNatPOJO.getProtocol() + ";");
                          }
                          else if (customPOJO .getProtocol().equals(protocol))
                          {
                              valueString.append(customPOJO .getPort() + ":"+ protocol + ";");
                          } 
                          else
                          {   throw new RemoteException("Invalid Argument: Unsupported protocol "+ protocol);
                          }
                      }
                      if (valueString.length() == 0)
                      {
                          return generateErrorResponse("No info found");
                      }
                      responseMap.put(keyString.toString(), valueString.toString());
                  }
  
  }
  </code></pre>
  
  <p>The weird behavior which is happening is that while iterating through the customPOJO its coming inside elseIf and also setting the value in valueString by executing below code:</p>
  
  <pre><code>else if (customPOJO .getProtocol().equals(protocol))
                      {
                          valueString.append(customPOJO .getPort() + ":"+ protocol + ";");
                      } 
  </code></pre>
  
  <p>After this elseif its coming directly on line </p>
  
  <pre><code>throw new RemoteException("Invalid Argument: Unsupported protocol "+ protocol);
  </code></pre>
  
  <p>There is no error which is coming in append operation and checked in debug perspective the value is getting appended successfully in valueString.</p>
  
  <p>Please tell what i am missing </p>