Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 3d78b5d

Browse files
Michal GajdošGerrit Code Review
authored andcommitted
Merge "JERSEY-2621 JarFileScanner ignores recursive flag on Windows"
2 parents 9f7c45c + cc89c97 commit 3d78b5d

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

core-server/src/main/java/org/glassfish/jersey/server/internal/scanning/JarFileScanner.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2012-2014 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -39,7 +39,6 @@
3939
*/
4040
package org.glassfish.jersey.server.internal.scanning;
4141

42-
import java.io.File;
4342
import java.io.IOException;
4443
import java.io.InputStream;
4544
import java.util.NoSuchElementException;
@@ -57,7 +56,9 @@
5756
*/
5857
public final class JarFileScanner implements ResourceFinder {
5958

60-
private final static Logger LOGGER = Logger.getLogger(JarFileScanner.class.getName());
59+
private static final Logger LOGGER = Logger.getLogger(JarFileScanner.class.getName());
60+
// platform independent file separator within the jar file
61+
private static final char JAR_FILE_SEPARATOR = '\\';
6162

6263
private final JarInputStream jarInputStream;
6364
private final String parent;
@@ -72,7 +73,7 @@ public final class JarFileScanner implements ResourceFinder {
7273
* {@code false} only the explicitly listed packages will be scanned.
7374
* @throws IOException if wrapping given input stream into {@link JarInputStream} failed.
7475
*/
75-
public JarFileScanner(InputStream inputStream, String parent, boolean recursive) throws IOException {
76+
public JarFileScanner(final InputStream inputStream, final String parent, final boolean recursive) throws IOException {
7677
this.jarInputStream = new JarInputStream(inputStream);
7778
this.parent = parent;
7879
this.recursive = recursive;
@@ -95,16 +96,16 @@ public boolean hasNext() {
9596
break;
9697
}
9798
// accept only entries directly in the folder.
98-
String suffix = next.getName().substring(parent.length());
99-
if (suffix.lastIndexOf(File.separatorChar) <= 0) {
99+
final String suffix = next.getName().substring(parent.length());
100+
if (suffix.lastIndexOf(JAR_FILE_SEPARATOR) <= 0) {
100101
break;
101102
}
102103
}
103104
} while (true);
104-
} catch (IOException e) {
105+
} catch (final IOException e) {
105106
LOGGER.log(Level.CONFIG, "Unable to read the next jar entry.", e);
106107
return false;
107-
} catch (SecurityException e) {
108+
} catch (final SecurityException e) {
108109
LOGGER.log(Level.CONFIG, "Unable to read the next jar entry.", e);
109110
return false;
110111
}
@@ -113,7 +114,7 @@ public boolean hasNext() {
113114
if (next == null) {
114115
try {
115116
jarInputStream.close();
116-
} catch (IOException e) {
117+
} catch (final IOException e) {
117118
LOGGER.log(Level.FINE, "Unable to close jar file.", e);
118119
}
119120

@@ -154,17 +155,17 @@ public int read() throws IOException {
154155
}
155156

156157
@Override
157-
public int read(byte[] bytes) throws IOException {
158+
public int read(final byte[] bytes) throws IOException {
158159
return jarInputStream.read(bytes);
159160
}
160161

161162
@Override
162-
public int read(byte[] bytes, int i, int i2) throws IOException {
163+
public int read(final byte[] bytes, final int i, final int i2) throws IOException {
163164
return jarInputStream.read(bytes, i, i2);
164165
}
165166

166167
@Override
167-
public long skip(long l) throws IOException {
168+
public long skip(final long l) throws IOException {
168169
return jarInputStream.skip(l);
169170
}
170171

@@ -179,7 +180,7 @@ public void close() throws IOException {
179180
}
180181

181182
@Override
182-
public synchronized void mark(int i) {
183+
public synchronized void mark(final int i) {
183184
jarInputStream.mark(i);
184185
}
185186

0 commit comments

Comments
 (0)