Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
f3d4b3e5
Commit
f3d4b3e5
authored
Nov 03, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow entries to be streamed from JarURLConnections' jar file
Fixes gh-23821
parent
2d9d40bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
1 deletion
+33
-1
JarFileWrapper.java
...a/org/springframework/boot/loader/jar/JarFileWrapper.java
+6
-0
JarFileWrapperTests.java
.../springframework/boot/loader/jar/JarFileWrapperTests.java
+16
-1
JarURLConnectionTests.java
...pringframework/boot/loader/jar/JarURLConnectionTests.java
+11
-0
No files found.
spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileWrapper.java
View file @
f3d4b3e5
...
@@ -24,6 +24,7 @@ import java.security.Permission;
...
@@ -24,6 +24,7 @@ import java.security.Permission;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.jar.JarEntry
;
import
java.util.jar.JarEntry
;
import
java.util.jar.Manifest
;
import
java.util.jar.Manifest
;
import
java.util.stream.Stream
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
/**
/**
...
@@ -67,6 +68,11 @@ class JarFileWrapper extends AbstractJarFile {
...
@@ -67,6 +68,11 @@ class JarFileWrapper extends AbstractJarFile {
return
this
.
parent
.
entries
();
return
this
.
parent
.
entries
();
}
}
@Override
public
Stream
<
JarEntry
>
stream
()
{
return
this
.
parent
.
stream
();
}
@Override
@Override
public
JarEntry
getJarEntry
(
String
name
)
{
public
JarEntry
getJarEntry
(
String
name
)
{
return
this
.
parent
.
getJarEntry
(
name
);
return
this
.
parent
.
getJarEntry
(
name
);
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileWrapperTests.java
View file @
f3d4b3e5
...
@@ -28,6 +28,7 @@ import java.util.Enumeration;
...
@@ -28,6 +28,7 @@ import java.util.Enumeration;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.jar.JarOutputStream
;
import
java.util.jar.JarOutputStream
;
import
java.util.jar.Manifest
;
import
java.util.jar.Manifest
;
import
java.util.stream.Stream
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.AfterEach
;
...
@@ -150,6 +151,12 @@ class JarFileWrapperTests {
...
@@ -150,6 +151,12 @@ class JarFileWrapperTests {
.
isThrownBy
(()
->
JarFileWrapper
.
class
.
getDeclaredMethod
(
"close"
));
.
isThrownBy
(()
->
JarFileWrapper
.
class
.
getDeclaredMethod
(
"close"
));
}
}
@Test
void
streamDelegatestoParent
()
{
this
.
wrapper
.
stream
();
this
.
parent
.
verify
(
Call
.
STREAM
);
}
/**
/**
* {@link JarFile} that we can spy (even on Java 11+)
* {@link JarFile} that we can spy (even on Java 11+)
*/
*/
...
@@ -179,6 +186,12 @@ class JarFileWrapperTests {
...
@@ -179,6 +186,12 @@ class JarFileWrapperTests {
return
super
.
entries
();
return
super
.
entries
();
}
}
@Override
public
Stream
<
java
.
util
.
jar
.
JarEntry
>
stream
()
{
mark
(
Call
.
STREAM
);
return
super
.
stream
();
}
@Override
@Override
public
JarEntry
getJarEntry
(
String
name
)
{
public
JarEntry
getJarEntry
(
String
name
)
{
mark
(
Call
.
GET_JAR_ENTRY
);
mark
(
Call
.
GET_JAR_ENTRY
);
...
@@ -257,7 +270,9 @@ class JarFileWrapperTests {
...
@@ -257,7 +270,9 @@ class JarFileWrapperTests {
GET_COMMENT
,
GET_COMMENT
,
SIZE
SIZE
,
STREAM
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarURLConnectionTests.java
View file @
f3d4b3e5
...
@@ -21,6 +21,9 @@ import java.io.File;
...
@@ -21,6 +21,9 @@ import java.io.File;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.net.URL
;
import
java.util.List
;
import
java.util.jar.JarEntry
;
import
java.util.stream.Collectors
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.BeforeEach
;
...
@@ -201,6 +204,14 @@ class JarURLConnectionTests {
...
@@ -201,6 +204,14 @@ class JarURLConnectionTests {
assertThat
(
connection
.
getLastModified
()).
isEqualTo
(
connection
.
getJarEntry
().
getTime
());
assertThat
(
connection
.
getLastModified
()).
isEqualTo
(
connection
.
getJarEntry
().
getTime
());
}
}
@Test
void
entriesCanBeStreamedFromJarFileOfConnection
()
throws
Exception
{
URL
url
=
new
URL
(
"jar:"
+
this
.
rootJarFile
.
toURI
().
toURL
()
+
"!/"
);
JarURLConnection
connection
=
JarURLConnection
.
get
(
url
,
this
.
jarFile
);
List
<
String
>
entryNames
=
connection
.
getJarFile
().
stream
().
map
(
JarEntry:
:
getName
).
collect
(
Collectors
.
toList
());
assertThat
(
entryNames
).
hasSize
(
12
);
}
@Test
@Test
void
jarEntryBasicName
()
{
void
jarEntryBasicName
()
{
assertThat
(
new
JarEntryName
(
new
StringSequence
(
"a/b/C.class"
)).
toString
()).
isEqualTo
(
"a/b/C.class"
);
assertThat
(
new
JarEntryName
(
new
StringSequence
(
"a/b/C.class"
)).
toString
()).
isEqualTo
(
"a/b/C.class"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment