Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bc5b0ab

Browse filesBrowse files
committed
Reducing duplicate code in MRJAR using VersionSpecifics class
Signed-off-by: Markus KARG <markus@headcrashing.eu>
1 parent be51d3a commit bc5b0ab
Copy full SHA for bc5b0ab

File tree

Expand file treeCollapse file tree

7 files changed

+100
-1774
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+100
-1774
lines changed
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.codehaus.plexus.util;
2+
3+
import java.io.IOException;
4+
import java.io.InputStream;
5+
import java.io.OutputStream;
6+
import java.io.Reader;
7+
import java.io.Writer;
8+
9+
/**
10+
* Fallback implementation for all Java SE versions not
11+
* overwriting a method version-specifically.
12+
*/
13+
abstract class CommonImplementation
14+
{
15+
private static final int DEFAULT_BUFFER_SIZE = 1024 * 16;
16+
17+
void copy( final InputStream input, final OutputStream output )
18+
throws IOException
19+
{
20+
IOUtil.copy( input, output, DEFAULT_BUFFER_SIZE );
21+
}
22+
23+
void copy( final Reader input, final Writer output )
24+
throws IOException
25+
{
26+
IOUtil.copy( input, output, DEFAULT_BUFFER_SIZE );
27+
}
28+
29+
}

‎src/main/java/org/codehaus/plexus/util/IOUtil.java

Copy file name to clipboardExpand all lines: src/main/java/org/codehaus/plexus/util/IOUtil.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private IOUtil()
156156
public static void copy( final InputStream input, final OutputStream output )
157157
throws IOException
158158
{
159-
copy( input, output, DEFAULT_BUFFER_SIZE );
159+
VersionSpecifics.INSTANCE.copy( input, output );
160160
}
161161

162162
/**
@@ -186,7 +186,7 @@ public static void copy( final InputStream input, final OutputStream output, fin
186186
public static void copy( final Reader input, final Writer output )
187187
throws IOException
188188
{
189-
copy( input, output, DEFAULT_BUFFER_SIZE );
189+
VersionSpecifics.INSTANCE.copy( input, output );
190190
}
191191

192192
/**
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.codehaus.plexus.util;
2+
3+
/**
4+
* Implementation specific to Java SE 8 version.
5+
*/
6+
final class VersionSpecifics extends CommonImplementation
7+
{
8+
static final VersionSpecifics INSTANCE = new VersionSpecifics();
9+
10+
private VersionSpecifics() {
11+
// singleton
12+
}
13+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.