Skip to content

Commit a46315e

Browse files
committed
gh-4610 Fix CS and failing test
1 parent b32581a commit a46315e

File tree

3 files changed

+42
-38
lines changed

3 files changed

+42
-38
lines changed

stroom-app/src/test/java/stroom/importexport/TestJsonSerialisation.java

+22-23
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Stream<DynamicTest> testDefaultValues() {
130130
return buildRelatedResourceTests(clazz -> {
131131
// Try and find the no args constructor if there is any.
132132
if (!Modifier.isInterface(clazz.getModifiers())
133-
&& !Modifier.isAbstract(clazz.getModifiers())) {
133+
&& !Modifier.isAbstract(clazz.getModifiers())) {
134134

135135
final Constructor<?>[] constructors = clazz.getDeclaredConstructors();
136136
Constructor<?> noArgsConstructor = null;
@@ -164,7 +164,6 @@ Stream<DynamicTest> testDefaultValues() {
164164
}
165165
}
166166
});
167-
168167
}
169168

170169
/**
@@ -181,7 +180,7 @@ Stream<DynamicTest> testNoComplexMaps() {
181180
for (final Field field : fields) {
182181
// Don't care about static as they are not serialised.
183182
if (Map.class.isAssignableFrom(field.getType())
184-
&& !Modifier.isStatic(field.getModifiers())) {
183+
&& !Modifier.isStatic(field.getModifiers())) {
185184
final ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType();
186185
final Type keyType = parameterizedType.getActualTypeArguments()[0];
187186
if (!(keyType instanceof Class && ((Class<?>) keyType).isEnum())) {
@@ -286,8 +285,8 @@ Stream<DynamicTest> testJsonAnnotations() {
286285
return buildRelatedResourceTests(clazz -> {
287286

288287
if (!Modifier.isInterface(clazz.getModifiers())
289-
&& !Modifier.isAbstract(clazz.getModifiers())
290-
&& !clazz.isEnum()) {
288+
&& !Modifier.isAbstract(clazz.getModifiers())
289+
&& !clazz.isEnum()) {
291290
final boolean hasJsonInclude = clazz.getAnnotation(JsonInclude.class) != null;
292291
final boolean hasJsonPropertyOrder = clazz.getAnnotation(JsonPropertyOrder.class) != null;
293292
final AtomicInteger jsonCreatorCount = new AtomicInteger(0);
@@ -313,7 +312,7 @@ Stream<DynamicTest> testJsonAnnotations() {
313312

314313
fieldPropNames = getAllFields(clazz).stream()
315314
.filter(field -> field.getDeclaredAnnotation(JsonIgnore.class) == null
316-
&& field.getDeclaredAnnotation(JsonProperty.class) != null)
315+
&& field.getDeclaredAnnotation(JsonProperty.class) != null)
317316
.map(field -> {
318317
final JsonProperty jsonProperty = field.getDeclaredAnnotation(JsonProperty.class);
319318
if (!jsonProperty.value().isEmpty()) {
@@ -331,8 +330,8 @@ Stream<DynamicTest> testJsonAnnotations() {
331330
final JsonIgnore jsonIgnore = field.getDeclaredAnnotation(JsonIgnore.class);
332331
final JsonProperty jsonProperty = field.getDeclaredAnnotation(JsonProperty.class);
333332
if (jsonIgnore == null
334-
&& jsonProperty == null
335-
&& !Modifier.isStatic(field.getModifiers())) {
333+
&& jsonProperty == null
334+
&& !Modifier.isStatic(field.getModifiers())) {
336335
String fieldName = field.getName();
337336
fieldsWithoutAnnotations.add(fieldName);
338337
}
@@ -349,7 +348,7 @@ Stream<DynamicTest> testJsonAnnotations() {
349348
SoftAssertions.assertSoftly(softly -> {
350349
softly.assertThat(constructorPropNames)
351350
.describedAs("%s - JsonProperties defined in the constructor must have a " +
352-
"corresponding JsonProperty on the field.", clazz.getName())
351+
"corresponding JsonProperty on the field.", clazz.getName())
353352
.containsExactlyInAnyOrderElementsOf(fieldPropNames);
354353

355354
softly.assertThat(hasJsonInclude)
@@ -506,16 +505,16 @@ private String normaliseFieldName(final String fieldName) {
506505

507506
private boolean isGetter(final Method method) {
508507
return !Modifier.isAbstract(method.getModifiers()) &&
509-
Modifier.isPublic(method.getModifiers()) &&
510-
method.getParameterCount() == 0 &&
511-
(method.getName().startsWith("is") || method.getName().startsWith("get"));
508+
Modifier.isPublic(method.getModifiers()) &&
509+
method.getParameterCount() == 0 &&
510+
(method.getName().startsWith("is") || method.getName().startsWith("get"));
512511
}
513512

514513
private boolean isSetter(final Method method) {
515514
return !Modifier.isAbstract(method.getModifiers()) &&
516-
Modifier.isPublic(method.getModifiers()) &&
517-
method.getParameterCount() == 1 &&
518-
method.getName().startsWith("set");
515+
Modifier.isPublic(method.getModifiers()) &&
516+
method.getParameterCount() == 1 &&
517+
method.getName().startsWith("set");
519518
}
520519

521520
private String convertMethodToFieldName(final String methodName) {
@@ -589,7 +588,7 @@ private static void addClass(final Set<Class<?>> stroomClasses, final Class<?> c
589588
}
590589

591590
} else if (clazz.getName().startsWith(PACKAGE_START)
592-
&& !clazz.getName().contains("StroomDuration")) { // Non POJO
591+
&& !clazz.getName().contains("StroomDuration")) { // Non POJO
593592
// IF the class references sub classes then include those too.
594593
final JsonSubTypes jsonSubTypes = clazz.getAnnotation(JsonSubTypes.class);
595594
if (jsonSubTypes != null) {
@@ -667,16 +666,16 @@ private List<Class<?>> getSharedClasses() {
667666
// LOGGER.info("{}", routeClassInfo.getName());
668667
final String name = routeClassInfo.getName();
669668
if (name.contains(".shared.") &&
670-
!name.contains("hadoopcommonshaded") &&
671-
!name.contains("Util") &&
672-
!name.contains("$") &&
673-
!name.contains("_")) {
669+
!name.contains("hadoopcommonshaded") &&
670+
!name.contains("Util") &&
671+
!name.contains("$") &&
672+
!name.contains("_")) {
674673
try {
675674
final Class<?> clazz = routeClassInfo.loadClass();
676675
if (!Modifier.isInterface(clazz.getModifiers()) &&
677-
!Modifier.isAbstract(clazz.getModifiers()) &&
678-
!RestResource.class.isAssignableFrom(clazz) &&
679-
!DirectRestService.class.isAssignableFrom(clazz)) {
676+
!Modifier.isAbstract(clazz.getModifiers()) &&
677+
!RestResource.class.isAssignableFrom(clazz) &&
678+
!DirectRestService.class.isAssignableFrom(clazz)) {
680679
stroomClasses.add(clazz);
681680
}
682681
} catch (final IllegalArgumentException e) {

stroom-lmdb/src/main/java/stroom/lmdb/LmdbEnv.java

+19-14
Original file line numberDiff line numberDiff line change
@@ -604,27 +604,17 @@ public void compact() {
604604
private void compact(final long currSizeOnDisk) {
605605
Path tempEnvDir = null;
606606
try {
607+
// Create the temp dir inside localDir as the ref data could be quite large so may blow up
608+
// /tmp
607609
tempEnvDir = Files.createTempDirectory(localDir, "lmdb-env-clone-");
608610
LOGGER.info("Starting compacting copy of LMDB env '{}' from {} to {}, current size on disk: {}",
609611
name, localDir, tempEnvDir, ByteSize.ofBytes(currSizeOnDisk));
610-
final Path finalTempEnvDir = tempEnvDir;
611-
final Duration compactDuration = DurationTimer.measure(() -> {
612-
// Copy the whole env, compacting as it goes
613-
env.copy(finalTempEnvDir.toFile(), CopyFlags.MDB_CP_COMPACT);
614-
// Close the source env and its dbis
615-
close();
616-
// Delete the source
617-
deleteEnvFiles(localDir);
618-
// Move temp env back to source
619-
moveEnvFiles(finalTempEnvDir, localDir);
620-
// Open it back up
621-
reOpenEnv();
622-
});
612+
final Duration compactDuration = doCompact(tempEnvDir);
623613

624614
long newSizeOnDisk = getSizeOnDisk();
625615
double pct = ((1 - (((double) newSizeOnDisk) / currSizeOnDisk))) * 100;
626616
final DecimalFormat decimalFormat = new DecimalFormat("0.0");
627-
// 0% bad, 100% good
617+
// 0% == no compaction, 100% == Full compaction
628618
LOGGER.info(
629619
"Completed compacting copy of LMDB env '{}' from {} to {} in {}, " +
630620
"size on disk: {} => {} (compaction {}%)",
@@ -645,6 +635,21 @@ private void compact(final long currSizeOnDisk) {
645635
}
646636
}
647637

638+
private Duration doCompact(final Path finalTempEnvDir) {
639+
final DurationTimer timer = DurationTimer.start();
640+
// Copy the whole env to a temporary dir, compacting as it goes
641+
env.copy(finalTempEnvDir.toFile(), CopyFlags.MDB_CP_COMPACT);
642+
// Close the source env and its dbis
643+
close();
644+
// Delete the source
645+
deleteEnvFiles(localDir);
646+
// Move temp env back to source
647+
moveEnvFiles(finalTempEnvDir, localDir);
648+
// Open it back up
649+
reOpenEnv();
650+
return timer.get();
651+
}
652+
648653
private Runnable createWaitLoggingAction(final String lockName) {
649654
final Instant startTime = Instant.now();
650655
LOGGER.trace("About to acquire {}", lockName);

stroom-pipeline/src/main/java/stroom/pipeline/refdata/ReferenceDataConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public StroomDuration getPurgeAge() {
109109
return purgeAge;
110110
}
111111

112-
@JsonPropertyDescription("")
112+
@JsonPropertyDescription("TODO")
113113
public boolean isAutoPurgeEnabled() {
114114
return autoPurgeEnabled;
115115
}

0 commit comments

Comments
 (0)