Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.0
-
None
-
Patch
Description
IOGroovyMethods.withStream currently defines the closure parameter as InputStream. If withStream is used on a subclass of InputStream, then that type information isn't available.
Here's an example that should compile, but does not:
new ByteArrayInputStream(new byte[5]) .withStream{ final ByteArrayInputStream stream -> }
In IOGroovyMethods, I suggest changing the method declaration from:
public static <T> T withStream(InputStream stream, @ClosureParams(value=SimpleType.class, options="java.io.InputStream") Closure<T> closure) throws IOException {
to:
public static <T, U extends InputStream> T withStream(U stream, @ClosureParams(value=FirstParam.class) Closure<T> closure) throws IOException {