Httpbinding bug

In org.jivesoftware.wildfire.HttpServerManager, method removeHttpBindServlet(Context), these two lines of code cause java.lang.UnsupportedOperationExceptions:

List<ServletHolder> toAddServlets = Arrays.asList(handler.getServlets());
toAddServlets.removeAll(httpBindContexts.keySet());

Arrays.asList() creates a fixed size List, which causes the removeAll() method to fail. If replaced by a new List declaration, all is well. E.g:

List<ServletHolder> toAddServlets = new ArrayList<ServletHolder>();
for(ServletHolder servlet : handler.getServlets()) {
    toAddServlets.add(servlet);
}
// List<ServletHolder> toAddServlets = Arrays.asList(handler.getServlets());
toAddServlets.removeAll(httpBindContexts.keySet());

This problem was harder to spot than usual, because the http-bind.jsp hides all exceptions: The JSP creates a Map in which it stores errors, but never outputs these errors.

Besides outputting the errors to the webpage, adding the errors to one of the logs is usefull as well: not all exceptions.getMessage() return non-empty Strings (the UnsupportedOperationExceptions described earlier didn’'t, for example).

Thanks guus for the tip I have checked in a fix for this and you can see it in subversion now. I will work on getting improved error reporting into the jsp.

Thanks,

Alex

Thanks Alex. As a quick fix, I copy and pasted some error warning code from other plugins, and adjusted it a bit to handle Exception.getMessage() calls that don’‘t return anything. Apart from this, I’'m also logging the entire exception.

Have a look, I’‘d give you a place to start at least. I’'ve inserted it right above the opening form tag in http-bind.jsp:

<%  if (errorMap.size() != 0) { %>     <div class="jive-error">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
        <tr><td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
        <td class="jive-icon-label">
          <% if (errorMap.containsKey("port")) { %>
          <%= ( (errorMap.get("port") == null) || errorMap.get("port").trim().equals("") )                ? "Errors occured while adjusting the port settings. Please review the logs for more information."                : errorMap.get("port") %>
          <% } %>
        </td></tr>
    </tbody>
    </table>
    </div><br> <%  } %>