private void updateRoutine(URL url, RoutineItem item) throws PersistenceException { InputStream stream = null; try { stream = url.openStream(); byte[] innerContent = new byte[stream.available()]; stream.read(innerContent); stream.close(); byte[] currentContent = item.getContent().getInnerContent(); if (!Arrays.equals(innerContent, currentContent)) { item.getContent().setInnerContent(innerContent); Project project = getRepositoryContext().getProject(); save(project, item); } } catch (IOException ioe) { if (stream != null) { try { stream.close(); } catch (IOException e) { throw new PersistenceException(ioe); } } throw new PersistenceException(ioe); } }