Skip to content

Commit 4c2c4ec

Browse files
committed
Merge branch '2.5.x'
2 parents 6c8c850 + 5ba6963 commit 4c2c4ec

File tree

4 files changed

+38
-19
lines changed
  • spring-boot-project
    • spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet
    • spring-boot-tools
      • spring-boot-loader/src/main/java/org/springframework/boot/loader/jar
      • spring-boot-maven-plugin/src/intTest/projects/build-image-multi-module/app/src/main/java/org/test
  • spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/spring-boot-server-tests-app/src/main/java/com/example

4 files changed

+38
-19
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,15 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
105105
}
106106
catch (Exception ex) {
107107
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
108-
record(timingContext, request, response, (ex instanceof NestedServletException) ? ex.getCause() : ex);
108+
record(timingContext, request, response, unwrapNestedServletException(ex));
109109
throw ex;
110110
}
111111
}
112112

113+
private Throwable unwrapNestedServletException(Throwable ex) {
114+
return (ex instanceof NestedServletException) ? ex.getCause() : ex;
115+
}
116+
113117
private TimingContext startAndAttachTimingContext(HttpServletRequest request) {
114118
Timer.Sample timerSample = Timer.start(this.registry);
115119
TimingContext timingContext = new TimingContext(timerSample);

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434

3535
/**
3636
* Provides access to entries from a {@link JarFile}. In order to reduce memory
37-
* consumption entry details are stored using int arrays. The {@code hashCodes} array
38-
* stores the hash code of the entry name, the {@code centralDirectoryOffsets} provides
39-
* the offset to the central directory record and {@code positions} provides the original
37+
* consumption entry details are stored using arrays. The {@code hashCodes} array stores
38+
* the hash code of the entry name, the {@code centralDirectoryOffsets} provides the
39+
* offset to the central directory record and {@code positions} provides the original
4040
* order position of the entry. The arrays are stored in hashCode order so that a binary
4141
* search can be used to find a name.
4242
* <p>
@@ -120,7 +120,7 @@ public void visitStart(CentralDirectoryEndRecord endRecord, RandomAccessData cen
120120
int maxSize = endRecord.getNumberOfRecords();
121121
this.centralDirectoryData = centralDirectoryData;
122122
this.hashCodes = new int[maxSize];
123-
this.centralDirectoryOffsets = Offsets.of(endRecord);
123+
this.centralDirectoryOffsets = Offsets.get(endRecord);
124124
this.positions = new int[maxSize];
125125
}
126126

@@ -187,12 +187,6 @@ private void swap(int i, int j) {
187187
swap(this.positions, i, j);
188188
}
189189

190-
private static void swap(int[] array, int i, int j) {
191-
int temp = array[i];
192-
array[i] = array[j];
193-
array[j] = temp;
194-
}
195-
196190
@Override
197191
public Iterator<JarEntry> iterator() {
198192
return new EntryIterator(NO_VALIDATION);
@@ -388,6 +382,18 @@ private int getEntryIndex(CharSequence name) {
388382
return -1;
389383
}
390384

385+
private static void swap(int[] array, int i, int j) {
386+
int temp = array[i];
387+
array[i] = array[j];
388+
array[j] = temp;
389+
}
390+
391+
private static void swap(long[] array, int i, int j) {
392+
long temp = array[i];
393+
array[i] = array[j];
394+
array[j] = temp;
395+
}
396+
391397
/**
392398
* Iterator for contained entries.
393399
*/
@@ -421,6 +427,11 @@ public JarEntry next() {
421427

422428
}
423429

430+
/**
431+
* Interface to manage offsets to central directory records. Regular zip files are
432+
* backed by an {@code int[]} based implementation, Zip64 files are backed by a
433+
* {@code long[]} and will consume more memory.
434+
*/
424435
private interface Offsets {
425436

426437
void set(int index, long value);
@@ -429,13 +440,16 @@ private interface Offsets {
429440

430441
void swap(int i, int j);
431442

432-
static Offsets of(CentralDirectoryEndRecord endRecord) {
433-
return endRecord.isZip64() ? new Zip64Offsets(endRecord.getNumberOfRecords())
434-
: new ZipOffsets(endRecord.getNumberOfRecords());
443+
static Offsets get(CentralDirectoryEndRecord endRecord) {
444+
int size = endRecord.getNumberOfRecords();
445+
return endRecord.isZip64() ? new Zip64Offsets(size) : new ZipOffsets(size);
435446
}
436447

437448
}
438449

450+
/**
451+
* {@link Offsets} implementation for regular zip files.
452+
*/
439453
private static final class ZipOffsets implements Offsets {
440454

441455
private final int[] offsets;
@@ -461,6 +475,9 @@ public long get(int index) {
461475

462476
}
463477

478+
/**
479+
* {@link Offsets} implementation for zip64 files.
480+
*/
464481
private static final class Zip64Offsets implements Offsets {
465482

466483
private final long[] offsets;
@@ -471,9 +488,7 @@ private Zip64Offsets(int size) {
471488

472489
@Override
473490
public void swap(int i, int j) {
474-
long temp = this.offsets[i];
475-
this.offsets[i] = this.offsets[j];
476-
this.offsets[j] = temp;
491+
JarFileEntries.swap(this.offsets, i, j);
477492
}
478493

479494
@Override

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-multi-module/app/src/main/java/org/test/SampleApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/spring-boot-server-tests-app/src/main/java/com/example/JettyServerCustomizerConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)