How about not deprecating it and hence not replacing any of its occurrences, but simply changing its implementation to delegate to IOUtils.copy(inputStream, outputStream) with the necessary try with resource block in one place instead of leaving it with every caller?
What you are suggesting makes a lot of sense! Though for cases like this particular one, where each caller would have to duplicate the try with resource block, wrapping it in a utility method looks …
It seems that to allow autoclosing you need to use a special try block. Never tried it though.
Both InputStream and OutputStream implement AutoCloseable, and its close method says:
void close() throws Exception
Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.
We probably need to deprecate OpenmrsUtil.copyFile(InputStream, InputStream) , the method name is misleading since it doesn’t really copy a file. And add a new one named OpenmrsUtil.copy(InputStream, InputStream)
Peeking at github, I see a lot of places where OpenmrsUtil.copyFile is used outside of openmrs-core.
What exactly is the point of deprecating (and then removing) this method, and then having to make sure that all these modules change their code in time for Platform 3.0?
I vote for just changing the implementation of OpenmrsUtil.copyFile to delegate to the apache version, so we’re not maintaining our own logic, but otherwise we let people who have been calling this continue to do so.