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
ff1983c9
Commit
ff1983c9
authored
Sep 06, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.1.x'
Closes gh-18168
parents
fc1889ee
795c2f22
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
0 deletions
+23
-0
CentralDirectoryEndRecord.java
...gframework/boot/loader/jar/CentralDirectoryEndRecord.java
+6
-0
JarFile.java
...ain/java/org/springframework/boot/loader/jar/JarFile.java
+8
-0
TestJarCreator.java
.../java/org/springframework/boot/loader/TestJarCreator.java
+2
-0
JarFileTests.java
...ava/org/springframework/boot/loader/jar/JarFileTests.java
+7
-0
No files found.
spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryEndRecord.java
View file @
ff1983c9
...
@@ -123,4 +123,10 @@ class CentralDirectoryEndRecord {
...
@@ -123,4 +123,10 @@ class CentralDirectoryEndRecord {
return
(
int
)
numberOfRecords
;
return
(
int
)
numberOfRecords
;
}
}
String
getComment
()
{
int
commentLength
=
(
int
)
Bytes
.
littleEndianValue
(
this
.
block
,
this
.
offset
+
COMMENT_LENGTH_OFFSET
,
2
);
AsciiBytes
comment
=
new
AsciiBytes
(
this
.
block
,
this
.
offset
+
COMMENT_LENGTH_OFFSET
+
2
,
commentLength
);
return
comment
.
toString
();
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java
View file @
ff1983c9
...
@@ -80,6 +80,8 @@ public class JarFile extends java.util.jar.JarFile {
...
@@ -80,6 +80,8 @@ public class JarFile extends java.util.jar.JarFile {
private
boolean
signed
;
private
boolean
signed
;
private
String
comment
;
/**
/**
* Create a new {@link JarFile} backed by the specified file.
* Create a new {@link JarFile} backed by the specified file.
* @param file the root jar file
* @param file the root jar file
...
@@ -146,6 +148,7 @@ public class JarFile extends java.util.jar.JarFile {
...
@@ -146,6 +148,7 @@ public class JarFile extends java.util.jar.JarFile {
@Override
@Override
public
void
visitStart
(
CentralDirectoryEndRecord
endRecord
,
RandomAccessData
centralDirectoryData
)
{
public
void
visitStart
(
CentralDirectoryEndRecord
endRecord
,
RandomAccessData
centralDirectoryData
)
{
JarFile
.
this
.
comment
=
endRecord
.
getComment
();
}
}
@Override
@Override
...
@@ -290,6 +293,11 @@ public class JarFile extends java.util.jar.JarFile {
...
@@ -290,6 +293,11 @@ public class JarFile extends java.util.jar.JarFile {
JarFileType
.
NESTED_JAR
);
JarFileType
.
NESTED_JAR
);
}
}
@Override
public
String
getComment
()
{
return
this
.
comment
;
}
@Override
@Override
public
int
size
()
{
public
int
size
()
{
return
this
.
entries
.
getSize
();
return
this
.
entries
.
getSize
();
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/TestJarCreator.java
View file @
ff1983c9
...
@@ -41,6 +41,7 @@ public abstract class TestJarCreator {
...
@@ -41,6 +41,7 @@ public abstract class TestJarCreator {
public
static
void
createTestJar
(
File
file
,
boolean
unpackNested
)
throws
Exception
{
public
static
void
createTestJar
(
File
file
,
boolean
unpackNested
)
throws
Exception
{
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
file
);
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
file
);
try
(
JarOutputStream
jarOutputStream
=
new
JarOutputStream
(
fileOutputStream
))
{
try
(
JarOutputStream
jarOutputStream
=
new
JarOutputStream
(
fileOutputStream
))
{
jarOutputStream
.
setComment
(
"outer"
);
writeManifest
(
jarOutputStream
,
"j1"
);
writeManifest
(
jarOutputStream
,
"j1"
);
writeEntry
(
jarOutputStream
,
"1.dat"
,
1
);
writeEntry
(
jarOutputStream
,
"1.dat"
,
1
);
writeEntry
(
jarOutputStream
,
"2.dat"
,
2
);
writeEntry
(
jarOutputStream
,
"2.dat"
,
2
);
...
@@ -88,6 +89,7 @@ public abstract class TestJarCreator {
...
@@ -88,6 +89,7 @@ public abstract class TestJarCreator {
private
static
byte
[]
getNestedJarData
(
boolean
multiRelease
)
throws
Exception
{
private
static
byte
[]
getNestedJarData
(
boolean
multiRelease
)
throws
Exception
{
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
JarOutputStream
jarOutputStream
=
new
JarOutputStream
(
byteArrayOutputStream
);
JarOutputStream
jarOutputStream
=
new
JarOutputStream
(
byteArrayOutputStream
);
jarOutputStream
.
setComment
(
"nested"
);
writeManifest
(
jarOutputStream
,
"j2"
,
multiRelease
);
writeManifest
(
jarOutputStream
,
"j2"
,
multiRelease
);
if
(
multiRelease
)
{
if
(
multiRelease
)
{
writeEntry
(
jarOutputStream
,
"multi-release.dat"
,
8
);
writeEntry
(
jarOutputStream
,
"multi-release.dat"
,
8
);
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java
View file @
ff1983c9
...
@@ -86,6 +86,7 @@ class JarFileTests {
...
@@ -86,6 +86,7 @@ class JarFileTests {
void
jdkJarFile
()
throws
Exception
{
void
jdkJarFile
()
throws
Exception
{
// Sanity checks to see how the default jar file operates
// Sanity checks to see how the default jar file operates
java
.
util
.
jar
.
JarFile
jarFile
=
new
java
.
util
.
jar
.
JarFile
(
this
.
rootJarFile
);
java
.
util
.
jar
.
JarFile
jarFile
=
new
java
.
util
.
jar
.
JarFile
(
this
.
rootJarFile
);
assertThat
(
jarFile
.
getComment
()).
isEqualTo
(
"outer"
);
Enumeration
<
java
.
util
.
jar
.
JarEntry
>
entries
=
jarFile
.
entries
();
Enumeration
<
java
.
util
.
jar
.
JarEntry
>
entries
=
jarFile
.
entries
();
assertThat
(
entries
.
nextElement
().
getName
()).
isEqualTo
(
"META-INF/"
);
assertThat
(
entries
.
nextElement
().
getName
()).
isEqualTo
(
"META-INF/"
);
assertThat
(
entries
.
nextElement
().
getName
()).
isEqualTo
(
"META-INF/MANIFEST.MF"
);
assertThat
(
entries
.
nextElement
().
getName
()).
isEqualTo
(
"META-INF/MANIFEST.MF"
);
...
@@ -168,6 +169,11 @@ class JarFileTests {
...
@@ -168,6 +169,11 @@ class JarFileTests {
assertThat
(
inputStream
.
read
()).
isEqualTo
(-
1
);
assertThat
(
inputStream
.
read
()).
isEqualTo
(-
1
);
}
}
@Test
void
getComment
()
{
assertThat
(
this
.
jarFile
.
getComment
()).
isEqualTo
(
"outer"
);
}
@Test
@Test
void
getName
()
{
void
getName
()
{
assertThat
(
this
.
jarFile
.
getName
()).
isEqualTo
(
this
.
rootJarFile
.
getPath
());
assertThat
(
this
.
jarFile
.
getName
()).
isEqualTo
(
this
.
rootJarFile
.
getPath
());
...
@@ -252,6 +258,7 @@ class JarFileTests {
...
@@ -252,6 +258,7 @@ class JarFileTests {
@Test
@Test
void
getNestedJarFile
()
throws
Exception
{
void
getNestedJarFile
()
throws
Exception
{
try
(
JarFile
nestedJarFile
=
this
.
jarFile
.
getNestedJarFile
(
this
.
jarFile
.
getEntry
(
"nested.jar"
)))
{
try
(
JarFile
nestedJarFile
=
this
.
jarFile
.
getNestedJarFile
(
this
.
jarFile
.
getEntry
(
"nested.jar"
)))
{
assertThat
(
nestedJarFile
.
getComment
()).
isEqualTo
(
"nested"
);
Enumeration
<
java
.
util
.
jar
.
JarEntry
>
entries
=
nestedJarFile
.
entries
();
Enumeration
<
java
.
util
.
jar
.
JarEntry
>
entries
=
nestedJarFile
.
entries
();
assertThat
(
entries
.
nextElement
().
getName
()).
isEqualTo
(
"META-INF/"
);
assertThat
(
entries
.
nextElement
().
getName
()).
isEqualTo
(
"META-INF/"
);
assertThat
(
entries
.
nextElement
().
getName
()).
isEqualTo
(
"META-INF/MANIFEST.MF"
);
assertThat
(
entries
.
nextElement
().
getName
()).
isEqualTo
(
"META-INF/MANIFEST.MF"
);
...
...
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