Skip to content

Commit 75945aa

Browse files
committed
#37: Deprecate Manifest(Reader) and update all related
Implemenation does not properly map characters to map and makes assumptions about character encoding which might lead to failures. Deprecate and rely on Java Manifest reader to do the right thing. This closes #37
1 parent 81d61cf commit 75945aa

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/main/java/org/codehaus/plexus/archiver/jar/Manifest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,10 @@ private void setManifestVersion()
780780
* @throws ManifestException if the manifest is not valid according
781781
* to the JAR spec
782782
* @throws IOException if the manifest cannot be read from the reader.
783+
* @deprecated This constructor does not properly map characters to bytes. Use
784+
* {@link #Manifest(InputStream)}. Will be removed in 4.0.
783785
*/
786+
@Deprecated
784787
public Manifest( Reader r )
785788
throws ManifestException, IOException
786789
{
@@ -937,6 +940,7 @@ public ExistingSection getSection( String name )
937940
}
938941

939942

943+
@Deprecated
940944
private static InputStream getInputStream( Reader r )
941945
throws IOException
942946
{

src/test/java/org/codehaus/plexus/archiver/jar/ManifestTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
*
1818
*/
1919

20-
import java.io.FileReader;
20+
import java.io.FileInputStream;
2121
import java.io.IOException;
22+
import java.io.InputStream;
2223
import java.io.PrintWriter;
2324
import java.io.StringWriter;
2425
import java.util.jar.Attributes;
@@ -31,15 +32,15 @@
3132
public class ManifestTest
3233
extends PlexusTestCase
3334
{
34-
public void testManifestReader1()
35+
public void testManifest1()
3536
throws Exception
3637
{
3738
Manifest manifest = getManifest( "src/test/resources/manifests/manifest1.mf" );
3839
String version = manifest.getManifestVersion();
3940
assertEquals( "Manifest was not created with correct version - ", "1.0", version );
4041
}
4142

42-
public void testManifestReader2()
43+
public void testManifest2()
4344
throws Exception
4445
{
4546
try
@@ -52,7 +53,7 @@ public void testManifestReader2()
5253
}
5354
}
5455

55-
public void testManifestReader3()
56+
public void testManifest3()
5657
throws Exception
5758
{
5859
try
@@ -65,7 +66,7 @@ public void testManifestReader3()
6566
}
6667
}
6768

68-
public void testManifestReader5()
69+
public void testManifest5()
6970
throws Exception
7071
{
7172
try
@@ -321,15 +322,15 @@ public void testAddConfiguredSectionPlexusManifest()
321322
private Manifest getManifest( String filename )
322323
throws IOException, ManifestException
323324
{
324-
FileReader r = new FileReader( getTestFile( filename ) );
325+
InputStream is = new FileInputStream( getTestFile( filename ) );
325326

326327
try
327328
{
328-
return new Manifest( r );
329+
return new Manifest( is );
329330
}
330331
finally
331332
{
332-
r.close();
333+
is.close();
333334
}
334335
}
335336

0 commit comments

Comments
 (0)