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
99750500
Commit
99750500
authored
Jan 12, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle files larger than Integer.MAX_VALUE bytes in bootJar and bootWar
Fixes gh-24618
parent
f02951fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
21 deletions
+26
-21
BootZipCopyAction.java
...amework/boot/gradle/tasks/bundling/BootZipCopyAction.java
+26
-21
No files found.
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java
View file @
99750500
...
@@ -32,6 +32,7 @@ import java.util.Set;
...
@@ -32,6 +32,7 @@ import java.util.Set;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.zip.CRC32
;
import
java.util.zip.CRC32
;
import
java.util.zip.ZipEntry
;
import
org.apache.commons.compress.archivers.zip.UnixStat
;
import
org.apache.commons.compress.archivers.zip.UnixStat
;
import
org.apache.commons.compress.archivers.zip.ZipArchiveEntry
;
import
org.apache.commons.compress.archivers.zip.ZipArchiveEntry
;
...
@@ -53,7 +54,6 @@ import org.springframework.boot.loader.tools.JarModeLibrary;
...
@@ -53,7 +54,6 @@ import org.springframework.boot.loader.tools.JarModeLibrary;
import
org.springframework.boot.loader.tools.Layer
;
import
org.springframework.boot.loader.tools.Layer
;
import
org.springframework.boot.loader.tools.LayersIndex
;
import
org.springframework.boot.loader.tools.LayersIndex
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.FileCopyUtils
;
import
org.springframework.util.StreamUtils
;
import
org.springframework.util.StreamUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -376,12 +376,7 @@ class BootZipCopyAction implements CopyAction {
...
@@ -376,12 +376,7 @@ class BootZipCopyAction implements CopyAction {
}
}
private
void
prepareStoredEntry
(
InputStream
input
,
ZipArchiveEntry
archiveEntry
)
throws
IOException
{
private
void
prepareStoredEntry
(
InputStream
input
,
ZipArchiveEntry
archiveEntry
)
throws
IOException
{
archiveEntry
.
setMethod
(
java
.
util
.
zip
.
ZipEntry
.
STORED
);
new
CrcAndSize
(
input
).
setUpStoredEntry
(
archiveEntry
);
Crc32OutputStream
crcStream
=
new
Crc32OutputStream
();
int
size
=
FileCopyUtils
.
copy
(
input
,
crcStream
);
archiveEntry
.
setSize
(
size
);
archiveEntry
.
setCompressedSize
(
size
);
archiveEntry
.
setCrc
(
crcStream
.
getCrc
());
}
}
private
Long
getTime
()
{
private
Long
getTime
()
{
...
@@ -464,29 +459,39 @@ class BootZipCopyAction implements CopyAction {
...
@@ -464,29 +459,39 @@ class BootZipCopyAction implements CopyAction {
}
}
/**
/**
*
An {@code OutputStream} that provides a CRC-32 of the data that is written to it
.
*
Data holder for CRC and Size
.
*/
*/
private
static
final
class
Crc32OutputStream
extends
OutputStream
{
private
static
class
CrcAndSize
{
private
static
final
int
BUFFER_SIZE
=
32
*
1024
;
private
final
CRC32
crc
=
new
CRC32
();
private
final
CRC32
crc
=
new
CRC32
();
@Override
private
long
size
;
public
void
write
(
int
b
)
throws
IOException
{
this
.
crc
.
update
(
b
);
}
@Override
CrcAndSize
(
InputStream
inputStream
)
throws
IOException
{
public
void
write
(
byte
[]
b
)
throws
IOException
{
try
{
this
.
crc
.
update
(
b
);
load
(
inputStream
);
}
finally
{
inputStream
.
close
();
}
}
}
@Override
private
void
load
(
InputStream
inputStream
)
throws
IOException
{
public
void
write
(
byte
[]
b
,
int
off
,
int
len
)
throws
IOException
{
byte
[]
buffer
=
new
byte
[
BUFFER_SIZE
];
this
.
crc
.
update
(
b
,
off
,
len
);
int
bytesRead
;
while
((
bytesRead
=
inputStream
.
read
(
buffer
))
!=
-
1
)
{
this
.
crc
.
update
(
buffer
,
0
,
bytesRead
);
this
.
size
+=
bytesRead
;
}
}
}
private
long
getCrc
()
{
void
setUpStoredEntry
(
ZipArchiveEntry
entry
)
{
return
this
.
crc
.
getValue
();
entry
.
setSize
(
this
.
size
);
entry
.
setCompressedSize
(
this
.
size
);
entry
.
setCrc
(
this
.
crc
.
getValue
());
entry
.
setMethod
(
ZipEntry
.
STORED
);
}
}
}
}
...
...
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