ObjectInputStream p = new ObjectInputStream(is); results = (Collection)p.readObject();
if (is != null) { ObjectInputStream p = new ObjectInputStream(is); results = (Collection)p.readObject(); is.close(); } else { if (log.isInfoEnabled()) { log.info("Got null input stream talking to " + urlSpec); } }
  public static Collection getCollectionFromAgent(String agentURL,                                                  String servletId,                                                  ArrayList parameterNames,                                                  ArrayList parameterValues,                                                  List data,                                                  int limit) {    Logger log = CSMART.createLogger("org.cougaar.tools.csmart.ui");    URLSpec.setBase(agentURL + servletId);    if (parameterNames != null)      URLSpec.addArgs(parameterNames, parameterValues);    if (limit >= 0)      URLSpec.addArg("limit", limit);    String urlSpec = URLSpec.getResult();    Collection results = null;    try {      URL url = new URL(urlSpec);      URLConnection connection = url.openConnection();      if (data != null) // force URL connection to use the PUT method for data        ((HttpURLConnection)connection).setRequestMethod("PUT");      connection.setDoInput(true);      connection.setDoOutput(true);      if (data != null) {        OutputStream os = connection.getOutputStream();        ObjectOutputStream oos = new ObjectOutputStream(os);        oos.writeObject(data);        oos.close();      }      InputStream is = connection.getInputStream();      ObjectInputStream p = new ObjectInputStream(is);      results = (Collection)p.readObject();    } catch (Exception e){      if (log.isErrorEnabled())        log.error("Exception contacting: " + urlSpec, e);    }    return results;  }