Java IllegalArgumentException in Zip FileSystem












0















I have a simple application which unzips a large number of Zip Files. It uses Files.walkFileTree() to walk the folders required and unzip them into an output folder.



There are over 1600 zip files. In a very few cases (3 to be precise) I get



Exception in thread "main" java.lang.IllegalArgumentException: MALFORMED[1]
at jdk.zipfs/jdk.nio.zipfs.ZipCoder.toString(ZipCoder.java:90)
at jdk.zipfs/jdk.nio.zipfs.ZipCoder$UTF8.toString(ZipCoder.java:64)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.getString(ZipFileSystem.java:938)
at jdk.zipfs/jdk.nio.zipfs.ZipPath.toString(ZipPath.java:603)
at utilities.DazUnzipper$2.visitFile(DazUnzipper.java:149)
at utilities.DazUnzipper$2.visitFile(DazUnzipper.java:1)
at java.base/java.nio.file.Files.walkFileTree(Files.java:2724)
at java.base/java.nio.file.Files.walkFileTree(Files.java:2796)
at utilities.DazUnzipper.unZip(BatchUnzipper.java:146)
at utilities.DazUnzipper.run(BatchUnzipper.java:104)
at utilities.DazUnzipper.main(BatchUnzipper.java:171)


In all of these failure cases, the zip file in question unzips without error using 7Zip.



I am using OpenJDK11. I have looked at the source of ZipCoder, and I am stumped. The toString() method takes a byte array as input, does some manipulation oif the byte array, checks the return code from a CoderResult.isUnderflow(), and throws IllegalArgumentException if it is false.



To quote from the doc:



"Underflow is reported when there is no more input to be processed, or there is insufficient input and additional input is required. This condition is represented by the unique result object UNDERFLOW, whose isUnderflow method returns true."










share|improve this question























  • Well, 7zip can open way more formats or varieties of zip-files than Java's zip library (iirc certain compression/encryption methods are not or at least have not been supported). That might be the problem ZipCoder runs into.

    – Thomas
    Nov 27 '18 at 15:43













  • Using 7zip I unzipped the file into a folder, and then created a new zip file from the results. It raises the same error. Many of these 1600 zips are created using 7zip, all using default settings, but do not fail.

    – casgage
    Nov 27 '18 at 15:53











  • Most likely, you have filenames in the zip file which are not using UTF-8 for non-ASCII characters. Try putting the correct charset name in the zip filesystem’s environment when you create it, under the key "encoding". For instance, envMap.put("encoding", "ISO_8559_1");.

    – VGR
    Nov 27 '18 at 16:02













  • Re my previous comment, The new zip file I created on this system, US English, had its name typed in by me on a US English keyboard, and it raised the same error. No thing but ASCII in the filenames. Nevertheless I will consider putting UTF-8 in there for completeness sake.

    – casgage
    Nov 27 '18 at 16:19
















0















I have a simple application which unzips a large number of Zip Files. It uses Files.walkFileTree() to walk the folders required and unzip them into an output folder.



There are over 1600 zip files. In a very few cases (3 to be precise) I get



Exception in thread "main" java.lang.IllegalArgumentException: MALFORMED[1]
at jdk.zipfs/jdk.nio.zipfs.ZipCoder.toString(ZipCoder.java:90)
at jdk.zipfs/jdk.nio.zipfs.ZipCoder$UTF8.toString(ZipCoder.java:64)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.getString(ZipFileSystem.java:938)
at jdk.zipfs/jdk.nio.zipfs.ZipPath.toString(ZipPath.java:603)
at utilities.DazUnzipper$2.visitFile(DazUnzipper.java:149)
at utilities.DazUnzipper$2.visitFile(DazUnzipper.java:1)
at java.base/java.nio.file.Files.walkFileTree(Files.java:2724)
at java.base/java.nio.file.Files.walkFileTree(Files.java:2796)
at utilities.DazUnzipper.unZip(BatchUnzipper.java:146)
at utilities.DazUnzipper.run(BatchUnzipper.java:104)
at utilities.DazUnzipper.main(BatchUnzipper.java:171)


In all of these failure cases, the zip file in question unzips without error using 7Zip.



I am using OpenJDK11. I have looked at the source of ZipCoder, and I am stumped. The toString() method takes a byte array as input, does some manipulation oif the byte array, checks the return code from a CoderResult.isUnderflow(), and throws IllegalArgumentException if it is false.



To quote from the doc:



"Underflow is reported when there is no more input to be processed, or there is insufficient input and additional input is required. This condition is represented by the unique result object UNDERFLOW, whose isUnderflow method returns true."










share|improve this question























  • Well, 7zip can open way more formats or varieties of zip-files than Java's zip library (iirc certain compression/encryption methods are not or at least have not been supported). That might be the problem ZipCoder runs into.

    – Thomas
    Nov 27 '18 at 15:43













  • Using 7zip I unzipped the file into a folder, and then created a new zip file from the results. It raises the same error. Many of these 1600 zips are created using 7zip, all using default settings, but do not fail.

    – casgage
    Nov 27 '18 at 15:53











  • Most likely, you have filenames in the zip file which are not using UTF-8 for non-ASCII characters. Try putting the correct charset name in the zip filesystem’s environment when you create it, under the key "encoding". For instance, envMap.put("encoding", "ISO_8559_1");.

    – VGR
    Nov 27 '18 at 16:02













  • Re my previous comment, The new zip file I created on this system, US English, had its name typed in by me on a US English keyboard, and it raised the same error. No thing but ASCII in the filenames. Nevertheless I will consider putting UTF-8 in there for completeness sake.

    – casgage
    Nov 27 '18 at 16:19














0












0








0








I have a simple application which unzips a large number of Zip Files. It uses Files.walkFileTree() to walk the folders required and unzip them into an output folder.



There are over 1600 zip files. In a very few cases (3 to be precise) I get



Exception in thread "main" java.lang.IllegalArgumentException: MALFORMED[1]
at jdk.zipfs/jdk.nio.zipfs.ZipCoder.toString(ZipCoder.java:90)
at jdk.zipfs/jdk.nio.zipfs.ZipCoder$UTF8.toString(ZipCoder.java:64)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.getString(ZipFileSystem.java:938)
at jdk.zipfs/jdk.nio.zipfs.ZipPath.toString(ZipPath.java:603)
at utilities.DazUnzipper$2.visitFile(DazUnzipper.java:149)
at utilities.DazUnzipper$2.visitFile(DazUnzipper.java:1)
at java.base/java.nio.file.Files.walkFileTree(Files.java:2724)
at java.base/java.nio.file.Files.walkFileTree(Files.java:2796)
at utilities.DazUnzipper.unZip(BatchUnzipper.java:146)
at utilities.DazUnzipper.run(BatchUnzipper.java:104)
at utilities.DazUnzipper.main(BatchUnzipper.java:171)


In all of these failure cases, the zip file in question unzips without error using 7Zip.



I am using OpenJDK11. I have looked at the source of ZipCoder, and I am stumped. The toString() method takes a byte array as input, does some manipulation oif the byte array, checks the return code from a CoderResult.isUnderflow(), and throws IllegalArgumentException if it is false.



To quote from the doc:



"Underflow is reported when there is no more input to be processed, or there is insufficient input and additional input is required. This condition is represented by the unique result object UNDERFLOW, whose isUnderflow method returns true."










share|improve this question














I have a simple application which unzips a large number of Zip Files. It uses Files.walkFileTree() to walk the folders required and unzip them into an output folder.



There are over 1600 zip files. In a very few cases (3 to be precise) I get



Exception in thread "main" java.lang.IllegalArgumentException: MALFORMED[1]
at jdk.zipfs/jdk.nio.zipfs.ZipCoder.toString(ZipCoder.java:90)
at jdk.zipfs/jdk.nio.zipfs.ZipCoder$UTF8.toString(ZipCoder.java:64)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.getString(ZipFileSystem.java:938)
at jdk.zipfs/jdk.nio.zipfs.ZipPath.toString(ZipPath.java:603)
at utilities.DazUnzipper$2.visitFile(DazUnzipper.java:149)
at utilities.DazUnzipper$2.visitFile(DazUnzipper.java:1)
at java.base/java.nio.file.Files.walkFileTree(Files.java:2724)
at java.base/java.nio.file.Files.walkFileTree(Files.java:2796)
at utilities.DazUnzipper.unZip(BatchUnzipper.java:146)
at utilities.DazUnzipper.run(BatchUnzipper.java:104)
at utilities.DazUnzipper.main(BatchUnzipper.java:171)


In all of these failure cases, the zip file in question unzips without error using 7Zip.



I am using OpenJDK11. I have looked at the source of ZipCoder, and I am stumped. The toString() method takes a byte array as input, does some manipulation oif the byte array, checks the return code from a CoderResult.isUnderflow(), and throws IllegalArgumentException if it is false.



To quote from the doc:



"Underflow is reported when there is no more input to be processed, or there is insufficient input and additional input is required. This condition is represented by the unique result object UNDERFLOW, whose isUnderflow method returns true."







java zip illegalargumentexception






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 27 '18 at 15:40









casgagecasgage

199414




199414













  • Well, 7zip can open way more formats or varieties of zip-files than Java's zip library (iirc certain compression/encryption methods are not or at least have not been supported). That might be the problem ZipCoder runs into.

    – Thomas
    Nov 27 '18 at 15:43













  • Using 7zip I unzipped the file into a folder, and then created a new zip file from the results. It raises the same error. Many of these 1600 zips are created using 7zip, all using default settings, but do not fail.

    – casgage
    Nov 27 '18 at 15:53











  • Most likely, you have filenames in the zip file which are not using UTF-8 for non-ASCII characters. Try putting the correct charset name in the zip filesystem’s environment when you create it, under the key "encoding". For instance, envMap.put("encoding", "ISO_8559_1");.

    – VGR
    Nov 27 '18 at 16:02













  • Re my previous comment, The new zip file I created on this system, US English, had its name typed in by me on a US English keyboard, and it raised the same error. No thing but ASCII in the filenames. Nevertheless I will consider putting UTF-8 in there for completeness sake.

    – casgage
    Nov 27 '18 at 16:19



















  • Well, 7zip can open way more formats or varieties of zip-files than Java's zip library (iirc certain compression/encryption methods are not or at least have not been supported). That might be the problem ZipCoder runs into.

    – Thomas
    Nov 27 '18 at 15:43













  • Using 7zip I unzipped the file into a folder, and then created a new zip file from the results. It raises the same error. Many of these 1600 zips are created using 7zip, all using default settings, but do not fail.

    – casgage
    Nov 27 '18 at 15:53











  • Most likely, you have filenames in the zip file which are not using UTF-8 for non-ASCII characters. Try putting the correct charset name in the zip filesystem’s environment when you create it, under the key "encoding". For instance, envMap.put("encoding", "ISO_8559_1");.

    – VGR
    Nov 27 '18 at 16:02













  • Re my previous comment, The new zip file I created on this system, US English, had its name typed in by me on a US English keyboard, and it raised the same error. No thing but ASCII in the filenames. Nevertheless I will consider putting UTF-8 in there for completeness sake.

    – casgage
    Nov 27 '18 at 16:19

















Well, 7zip can open way more formats or varieties of zip-files than Java's zip library (iirc certain compression/encryption methods are not or at least have not been supported). That might be the problem ZipCoder runs into.

– Thomas
Nov 27 '18 at 15:43







Well, 7zip can open way more formats or varieties of zip-files than Java's zip library (iirc certain compression/encryption methods are not or at least have not been supported). That might be the problem ZipCoder runs into.

– Thomas
Nov 27 '18 at 15:43















Using 7zip I unzipped the file into a folder, and then created a new zip file from the results. It raises the same error. Many of these 1600 zips are created using 7zip, all using default settings, but do not fail.

– casgage
Nov 27 '18 at 15:53





Using 7zip I unzipped the file into a folder, and then created a new zip file from the results. It raises the same error. Many of these 1600 zips are created using 7zip, all using default settings, but do not fail.

– casgage
Nov 27 '18 at 15:53













Most likely, you have filenames in the zip file which are not using UTF-8 for non-ASCII characters. Try putting the correct charset name in the zip filesystem’s environment when you create it, under the key "encoding". For instance, envMap.put("encoding", "ISO_8559_1");.

– VGR
Nov 27 '18 at 16:02







Most likely, you have filenames in the zip file which are not using UTF-8 for non-ASCII characters. Try putting the correct charset name in the zip filesystem’s environment when you create it, under the key "encoding". For instance, envMap.put("encoding", "ISO_8559_1");.

– VGR
Nov 27 '18 at 16:02















Re my previous comment, The new zip file I created on this system, US English, had its name typed in by me on a US English keyboard, and it raised the same error. No thing but ASCII in the filenames. Nevertheless I will consider putting UTF-8 in there for completeness sake.

– casgage
Nov 27 '18 at 16:19





Re my previous comment, The new zip file I created on this system, US English, had its name typed in by me on a US English keyboard, and it raised the same error. No thing but ASCII in the filenames. Nevertheless I will consider putting UTF-8 in there for completeness sake.

– casgage
Nov 27 '18 at 16:19












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53503153%2fjava-illegalargumentexception-in-zip-filesystem%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53503153%2fjava-illegalargumentexception-in-zip-filesystem%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks