What version of Go are you using (go version)?
go version devel +b1d1ec9183 Mon Apr 30 21:26:00 2018 +0000 linux/amd64
Does this issue reproduce with the latest release?
No. On tip.
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/antoninamand/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/antoninamand/go"
GORACE=""
GOROOT="/home/antoninamand/gotip"
GOTMPDIR=""
GOTOOLDIR="/home/antoninamand/gotip/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build168212714=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Unzip a zip file generated with go tip containing an empty directory. Unzipping raises an exception (java.util.zip.ZipException).
Create a zip with go:
package main
import (
"archive/zip"
"os"
)
func main() {
f, err := os.OpenFile(os.Args[1], os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
if err != nil {
panic(err)
}
z := zip.NewWriter(f)
_, err = z.Create("dir/")
if err != nil {
panic(err)
}
if err := z.Close(); err != nil {
panic(err)
}
if err := f.Close(); err != nil {
panic(err)
}
}
Unzip with java:
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class Main {
public static void main(String[] args) {
try {
FileInputStream fi = new FileInputStream(args[0]);
ZipInputStream z = new ZipInputStream(fi);
while (true) {
ZipEntry entry = z.getNextEntry();
if (entry == null) return;
System.out.println(entry.getName());
}
} catch (Exception e) {
e.printStackTrace();
System.exit(2);
}
}
}
Output:
go version
go version devel +b1d1ec9183 Mon Apr 30 21:26:00 2018 +0000 linux/amd64
go run zipfilewithdir.go file.zip
javac Main.java
java Main file.zip
dir/
java.util.zip.ZipException: invalid stored block lengths
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)
at java.util.zip.ZipInputStream.read(ZipInputStream.java:194)
at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:140)
at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:118)
at Main.main(Main.java:13)
Makefile:2: recipe for target 'run' failed
make: *** [run] Error 2
Note that the "dir/" entry is listed but it fails after that.
It doesn't fail when the archive is generated with go 1.10.1.
The compatibility was broken by 8cd00a5.
What did you expect to see?
It should unzip without error.
What did you see instead?
It raises a java exception.
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
No. On tip.
What operating system and processor architecture are you using (
go env)?What did you do?
Unzip a zip file generated with go tip containing an empty directory. Unzipping raises an exception (
java.util.zip.ZipException).Create a zip with go:
Unzip with java:
Output:
Note that the "dir/" entry is listed but it fails after that.
It doesn't fail when the archive is generated with go 1.10.1.
The compatibility was broken by 8cd00a5.
What did you expect to see?
It should unzip without error.
What did you see instead?
It raises a java exception.