Skip to content

Commit ef35266

Browse files
Pankraz76Vincent Potucek
andauthored
Bump spotless to 8.0.0 (#18770)
Co-authored-by: Vincent Potucek <[email protected]>
1 parent b67d076 commit ef35266

File tree

12 files changed

+103
-91
lines changed

12 files changed

+103
-91
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ plugins {
5555
id 'lifecycle-base'
5656
id 'opensearch.docker-support'
5757
id 'opensearch.global-build-info'
58-
id "com.diffplug.spotless" version "6.25.0" apply false
58+
id "com.diffplug.spotless" version "8.0.0" apply false
5959
id "org.gradle.test-retry" version "1.6.2" apply false
6060
id "test-report-aggregation"
6161
id 'jacoco-report-aggregation'

gradle/formatting.gradle

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ allprojects {
6666
target '**/*.java'
6767

6868
removeUnusedImports()
69+
forbidWildcardImports()
6970
importOrder(
7071
'de.thetaphi',
7172
'com.carrotsearch',
@@ -85,13 +86,6 @@ allprojects {
8586
trimTrailingWhitespace()
8687
endWithNewline()
8788

88-
custom 'Refuse wildcard imports', {
89-
// Wildcard imports can't be resolved; fail the build
90-
if (it =~ /\s+import .*\*;/) {
91-
throw new AssertionError("Do not use wildcard imports. 'spotlessApply' cannot resolve this issue.")
92-
}
93-
}
94-
9589
// See DEVELOPER_GUIDE.md for details of when to enable this.
9690
if (System.getProperty('spotless.paddedcell') != null) {
9791
paddedCell()

modules/autotagging-commons/src/test/java/org/opensearch/rule/labelresolver/FeatureValueResolverTests.java

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,12 @@ public void setUp() throws Exception {
5050
}
5151

5252
public void testResolveSingleIntersection() {
53-
when(attr1.findAttributeMatches(extractor1, store1)).thenReturn(Arrays.asList(
54-
new MatchLabel<>("a", 0.9f),
55-
new MatchLabel<>("b", 0.8f)
56-
));
57-
when(attr2.findAttributeMatches(extractor2, store2)).thenReturn(Arrays.asList(
58-
new MatchLabel<>("a", 0.95f),
59-
new MatchLabel<>("c", 0.7f)
60-
));
53+
when(attr1.findAttributeMatches(extractor1, store1)).thenReturn(
54+
Arrays.asList(new MatchLabel<>("a", 0.9f), new MatchLabel<>("b", 0.8f))
55+
);
56+
when(attr2.findAttributeMatches(extractor2, store2)).thenReturn(
57+
Arrays.asList(new MatchLabel<>("a", 0.95f), new MatchLabel<>("c", 0.7f))
58+
);
6159

6260
FeatureValueResolver resolver = new FeatureValueResolver(storeFactory, Arrays.asList(extractor1, extractor2));
6361
Optional<String> result = resolver.resolve();
@@ -66,44 +64,34 @@ public void testResolveSingleIntersection() {
6664
}
6765

6866
public void testResolveEmptyIntersection() {
69-
when(attr1.findAttributeMatches(extractor1, store1)).thenReturn(Arrays.asList(
70-
new MatchLabel<>("a", 0.9f)
71-
));
72-
when(attr2.findAttributeMatches(extractor2, store2)).thenReturn(Arrays.asList(
73-
new MatchLabel<>("b", 0.8f)
74-
));
67+
when(attr1.findAttributeMatches(extractor1, store1)).thenReturn(Arrays.asList(new MatchLabel<>("a", 0.9f)));
68+
when(attr2.findAttributeMatches(extractor2, store2)).thenReturn(Arrays.asList(new MatchLabel<>("b", 0.8f)));
7569

7670
FeatureValueResolver resolver = new FeatureValueResolver(storeFactory, Arrays.asList(extractor1, extractor2));
7771
Optional<String> result = resolver.resolve();
7872
assertFalse(result.isPresent());
7973
}
8074

8175
public void testResolveTieBreakingWithoutResult() {
82-
when(attr1.findAttributeMatches(extractor1, store1)).thenReturn(Arrays.asList(
83-
new MatchLabel<>("a", 0.9f),
84-
new MatchLabel<>("b", 0.9f),
85-
new MatchLabel<>("c", 0.7f)
86-
));
87-
when(attr2.findAttributeMatches(extractor2, store2)).thenReturn(Arrays.asList(
88-
new MatchLabel<>("a", 0.95f),
89-
new MatchLabel<>("b", 0.95f)
90-
));
76+
when(attr1.findAttributeMatches(extractor1, store1)).thenReturn(
77+
Arrays.asList(new MatchLabel<>("a", 0.9f), new MatchLabel<>("b", 0.9f), new MatchLabel<>("c", 0.7f))
78+
);
79+
when(attr2.findAttributeMatches(extractor2, store2)).thenReturn(
80+
Arrays.asList(new MatchLabel<>("a", 0.95f), new MatchLabel<>("b", 0.95f))
81+
);
9182

9283
FeatureValueResolver resolver = new FeatureValueResolver(storeFactory, Arrays.asList(extractor1, extractor2));
9384
Optional<String> result = resolver.resolve();
9485
assertFalse(result.isPresent());
9586
}
9687

9788
public void testResolveTieBreaking() {
98-
when(attr1.findAttributeMatches(extractor1, store1)).thenReturn(Arrays.asList(
99-
new MatchLabel<>("a", 0.9f),
100-
new MatchLabel<>("b", 0.9f),
101-
new MatchLabel<>("c", 0.7f)
102-
));
103-
when(attr2.findAttributeMatches(extractor2, store2)).thenReturn(Arrays.asList(
104-
new MatchLabel<>("b", 0.95f),
105-
new MatchLabel<>("a", 0.9f)
106-
));
89+
when(attr1.findAttributeMatches(extractor1, store1)).thenReturn(
90+
Arrays.asList(new MatchLabel<>("a", 0.9f), new MatchLabel<>("b", 0.9f), new MatchLabel<>("c", 0.7f))
91+
);
92+
when(attr2.findAttributeMatches(extractor2, store2)).thenReturn(
93+
Arrays.asList(new MatchLabel<>("b", 0.95f), new MatchLabel<>("a", 0.9f))
94+
);
10795

10896
FeatureValueResolver resolver = new FeatureValueResolver(storeFactory, Arrays.asList(extractor1, extractor2));
10997
Optional<String> result = resolver.resolve();
@@ -112,9 +100,7 @@ public void testResolveTieBreaking() {
112100
}
113101

114102
public void testResolveSingleExtractor() {
115-
when(attr1.findAttributeMatches(extractor1, store1)).thenReturn(Arrays.asList(
116-
new MatchLabel<>("x", 1.0f)
117-
));
103+
when(attr1.findAttributeMatches(extractor1, store1)).thenReturn(Arrays.asList(new MatchLabel<>("x", 1.0f)));
118104

119105
FeatureValueResolver resolver = new FeatureValueResolver(storeFactory, Collections.singletonList(extractor1));
120106
Optional<String> result = resolver.resolve();

plugins/arrow-flight-rpc/src/test/java/org/opensearch/arrow/flight/impl/BaseFlightProducerTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,9 @@ public void testGetFlightInfo_LocationNotFound() {
566566
}
567567

568568
public void testGetFlightInfo_SchemaError() {
569-
when(streamManager.getStreamProducer(any(FlightStreamTicket.class)))
570-
.thenReturn(Optional.of(FlightStreamManager.StreamProducerHolder.create(streamProducer, allocator)));
569+
when(streamManager.getStreamProducer(any(FlightStreamTicket.class))).thenReturn(
570+
Optional.of(FlightStreamManager.StreamProducerHolder.create(streamProducer, allocator))
571+
);
571572
Location location = Location.forGrpcInsecure("localhost", 8815);
572573
when(flightClientManager.getFlightClientLocation(LOCAL_NODE_ID)).thenReturn(Optional.of(location));
573574
when(streamProducer.createRoot(allocator)).thenReturn(mock(VectorSchemaRoot.class));

plugins/arrow-flight-rpc/src/test/java/org/opensearch/arrow/flight/impl/FlightStreamReaderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void tearDown() throws Exception {
5858
public void testNext_ReturnsTrue_WhenFlightStreamHasNext() throws Exception {
5959
when(mockFlightStream.next()).thenReturn(true);
6060
assertTrue(iterator.next());
61-
assert(mockFlightStream).next();
61+
assert (mockFlightStream).next();
6262
}
6363

6464
public void testNext_ReturnsFalse_WhenFlightStreamHasNoNext() throws Exception {

server/src/test/java/org/opensearch/action/admin/cluster/filecache/TransportPruneFileCacheActionTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,7 @@ public void testFileCacheException() {
237237
PruneFileCacheRequest globalRequest = new PruneFileCacheRequest();
238238
TransportPruneFileCacheAction.NodeRequest nodeRequest = new TransportPruneFileCacheAction.NodeRequest(globalRequest);
239239

240-
RuntimeException exception = expectThrows(
241-
RuntimeException.class,
242-
() -> action.nodeOperation(nodeRequest)
243-
);
240+
RuntimeException exception = expectThrows(RuntimeException.class, () -> action.nodeOperation(nodeRequest));
244241

245242
assertTrue("Exception should contain node ID", exception.getMessage().contains("node"));
246243
assertTrue("Exception should mention failure", exception.getMessage().contains("failed"));

server/src/test/java/org/opensearch/cluster/routing/remote/RemoteRoutingTableServiceTests.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,7 @@ public void testDeleteStaleIndexRoutingPathsThrowsIOException() throws IOExcepti
791791
doThrow(new IOException("test exception")).when(blobContainer).deleteBlobsIgnoringIfNotExists(Mockito.anyList());
792792

793793
remoteRoutingTableService.doStart();
794-
IOException thrown = assertThrows(IOException.class, () -> {
795-
remoteRoutingTableService.deleteStaleIndexRoutingPaths(stalePaths);
796-
});
794+
IOException thrown = assertThrows(IOException.class, () -> { remoteRoutingTableService.deleteStaleIndexRoutingPaths(stalePaths); });
797795
assertEquals("test exception", thrown.getMessage());
798796
verify(blobContainer).deleteBlobsIgnoringIfNotExists(stalePaths);
799797
}
@@ -814,9 +812,10 @@ public void testDeleteStaleIndexRoutingDiffPathsThrowsIOException() throws IOExc
814812
doThrow(new IOException("test exception")).when(blobContainer).deleteBlobsIgnoringIfNotExists(Mockito.anyList());
815813

816814
remoteRoutingTableService.doStart();
817-
IOException thrown = assertThrows(IOException.class, () -> {
818-
remoteRoutingTableService.deleteStaleIndexRoutingDiffPaths(stalePaths);
819-
});
815+
IOException thrown = assertThrows(
816+
IOException.class,
817+
() -> { remoteRoutingTableService.deleteStaleIndexRoutingDiffPaths(stalePaths); }
818+
);
820819
assertEquals("test exception", thrown.getMessage());
821820
verify(blobContainer).deleteBlobsIgnoringIfNotExists(stalePaths);
822821
}

server/src/test/java/org/opensearch/index/autoforcemerge/AutoForceMergeManagerTests.java

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ public void testNodeValidatorWithHealthyResources() {
255255
);
256256
when(threadPool.stats()).thenReturn(stats);
257257

258-
AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(getConfiguredClusterSettings(true, true, Collections.emptyMap()), getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE)));
258+
AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(
259+
getConfiguredClusterSettings(true, true, Collections.emptyMap()),
260+
getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE))
261+
);
259262
autoForceMergeManager.start();
260263
assertTrue(autoForceMergeManager.getNodeValidator().validate().isAllowed());
261264
autoForceMergeManager.close();
@@ -265,21 +268,25 @@ public void testNodeValidatorWithFeatureSwitch() {
265268
when(cpu.getPercent()).thenReturn((short) 50);
266269
when(jvm.getHeapUsedPercent()).thenReturn((short) 60);
267270
ThreadPoolStats stats = new ThreadPoolStats(
268-
Arrays.asList(new ThreadPoolStats.Stats.Builder().name(ThreadPool.Names.FORCE_MERGE)
269-
.threads(1)
270-
.queue(0)
271-
.active(0)
272-
.rejected(0)
273-
.largest(1)
274-
.completed(0)
275-
.waitTimeNanos(0)
276-
.parallelism(-1)
277-
.build()
271+
Arrays.asList(
272+
new ThreadPoolStats.Stats.Builder().name(ThreadPool.Names.FORCE_MERGE)
273+
.threads(1)
274+
.queue(0)
275+
.active(0)
276+
.rejected(0)
277+
.largest(1)
278+
.completed(0)
279+
.waitTimeNanos(0)
280+
.parallelism(-1)
281+
.build()
278282
)
279283
);
280284
when(threadPool.stats()).thenReturn(stats);
281285
Settings settings = getConfiguredClusterSettings(false, false, Collections.emptyMap());
282-
AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(settings, getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE)));
286+
AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(
287+
settings,
288+
getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE))
289+
);
283290
autoForceMergeManager.start();
284291
assertFalse(autoForceMergeManager.getConfigurationValidator().validate().isAllowed());
285292
assertNotEquals(Lifecycle.State.STARTED, ResourceTrackerProvider.resourceTrackers.cpuFiveMinute.lifecycleState());
@@ -327,22 +334,28 @@ public void testNodeValidatorWithHighCPU() {
327334
public void testNodeValidatorWithHighDiskUsage() {
328335
when(cpu.getPercent()).thenReturn((short) 50);
329336
when(disk.getAvailable()).thenReturn(new ByteSizeValue(5));
330-
AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(getConfiguredClusterSettings(true, true, Collections.emptyMap()), getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE)));
337+
AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(
338+
getConfiguredClusterSettings(true, true, Collections.emptyMap()),
339+
getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE))
340+
);
331341
autoForceMergeManager.start();
332342
assertFalse(autoForceMergeManager.getNodeValidator().validate().isAllowed());
333343
autoForceMergeManager.close();
334344
}
335345

336346
public void testNodeValidatorWithHighJVMUsage() {
337347
when(cpu.getPercent()).thenReturn((short) 50);
338-
AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(getConfiguredClusterSettings(true, true, Collections.emptyMap()), getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE)));
348+
AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(
349+
getConfiguredClusterSettings(true, true, Collections.emptyMap()),
350+
getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE))
351+
);
339352
autoForceMergeManager.start();
340353
when(jvm.getHeapUsedPercent()).thenReturn((short) 90);
341354
assertFalse(autoForceMergeManager.getNodeValidator().validate().isAllowed());
342-
for(int i = 0; i < 10; i++)
355+
for (int i = 0; i < 10; i++)
343356
ResourceTrackerProvider.resourceTrackers.jvmOneMinute.recordUsage(90);
344357
assertFalse(autoForceMergeManager.getNodeValidator().validate().isAllowed());
345-
for(int i = 0; i < 10; i++)
358+
for (int i = 0; i < 10; i++)
346359
ResourceTrackerProvider.resourceTrackers.jvmFiveMinute.recordUsage(90);
347360
assertFalse(autoForceMergeManager.getNodeValidator().validate().isAllowed());
348361
autoForceMergeManager.close();
@@ -366,7 +379,10 @@ public void testNodeValidatorWithInsufficientForceMergeThreads() {
366379
)
367380
);
368381
when(threadPool.stats()).thenReturn(stats);
369-
AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(getConfiguredClusterSettings(true, true, Collections.emptyMap()), getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE)));
382+
AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(
383+
getConfiguredClusterSettings(true, true, Collections.emptyMap()),
384+
getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE))
385+
);
370386
autoForceMergeManager.start();
371387
assertFalse(autoForceMergeManager.getNodeValidator().validate().isAllowed());
372388
ThreadPoolStats emptyStats = new ThreadPoolStats(Collections.emptyList());
@@ -678,13 +694,7 @@ private AutoForceMergeManager clusterSetupWithNode(Settings settings, DiscoveryN
678694
when(clusterService.getSettings()).thenReturn(settings);
679695
when(clusterService.localNode()).thenReturn(node);
680696

681-
return new AutoForceMergeManager(
682-
threadPool,
683-
monitorService,
684-
indicesService,
685-
clusterService,
686-
autoForceMergeMetrics
687-
);
697+
return new AutoForceMergeManager(threadPool, monitorService, indicesService, clusterService, autoForceMergeMetrics);
688698
}
689699

690700
public void testMergesSkippedNoWarmNodesMetric() {

server/src/test/java/org/opensearch/index/compositeindex/datacube/startree/builder/StarTreesBuilderTests.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,32 @@ public void test_buildWithNoStarTreeFields() throws IOException {
104104
public void test_getStarTreeBuilder() throws IOException {
105105
when(mapperService.getCompositeFieldTypes()).thenReturn(Set.of(starTreeFieldType));
106106
StarTreesBuilder starTreesBuilder = new StarTreesBuilder(segmentWriteState, mapperService, new AtomicInteger());
107-
StarTreeBuilder starTreeBuilder = starTreesBuilder.getStarTreeBuilder(metaOut, dataOut, starTreeField, segmentWriteState, mapperService);
107+
StarTreeBuilder starTreeBuilder = starTreesBuilder.getStarTreeBuilder(
108+
metaOut,
109+
dataOut,
110+
starTreeField,
111+
segmentWriteState,
112+
mapperService
113+
);
108114
assertTrue(starTreeBuilder instanceof OnHeapStarTreeBuilder);
109115
}
110116

111117
public void test_getStarTreeBuilder_illegalArgument() throws IOException {
112118
when(mapperService.getCompositeFieldTypes()).thenReturn(Set.of(starTreeFieldType));
113-
StarTreeFieldConfiguration starTreeFieldConfiguration = new StarTreeFieldConfiguration(1, new HashSet<>(), StarTreeFieldConfiguration.StarTreeBuildMode.OFF_HEAP);
119+
StarTreeFieldConfiguration starTreeFieldConfiguration = new StarTreeFieldConfiguration(
120+
1,
121+
new HashSet<>(),
122+
StarTreeFieldConfiguration.StarTreeBuildMode.OFF_HEAP
123+
);
114124
StarTreeField starTreeField = new StarTreeField("star_tree", new ArrayList<>(), new ArrayList<>(), starTreeFieldConfiguration);
115125
StarTreesBuilder starTreesBuilder = new StarTreesBuilder(segmentWriteState, mapperService, new AtomicInteger());
116-
StarTreeBuilder starTreeBuilder = starTreesBuilder.getStarTreeBuilder(metaOut, dataOut, starTreeField, segmentWriteState, mapperService);
126+
StarTreeBuilder starTreeBuilder = starTreesBuilder.getStarTreeBuilder(
127+
metaOut,
128+
dataOut,
129+
starTreeField,
130+
segmentWriteState,
131+
mapperService
132+
);
117133
assertTrue(starTreeBuilder instanceof OffHeapStarTreeBuilder);
118134
starTreeBuilder.close();
119135
}

server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryTests.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,12 @@ public void testGetPrimaryTermGenerationUuid() {
135135
}
136136

137137
public void testInitException() throws IOException {
138-
when(remoteMetadataDirectory.listFilesByPrefixInLexicographicOrder(RemoteSegmentStoreDirectory.MetadataFilenameUtils.METADATA_PREFIX, METADATA_FILES_TO_FETCH)).thenThrow(
139-
new IOException("Error")
140-
);
138+
when(
139+
remoteMetadataDirectory.listFilesByPrefixInLexicographicOrder(
140+
RemoteSegmentStoreDirectory.MetadataFilenameUtils.METADATA_PREFIX,
141+
METADATA_FILES_TO_FETCH
142+
)
143+
).thenThrow(new IOException("Error"));
141144

142145
assertThrows(IOException.class, () -> remoteSegmentStoreDirectory.init());
143146
}
@@ -155,9 +158,12 @@ public void testInitNoMetadataFile() throws IOException {
155158
}
156159

157160
public void testInitMultipleMetadataFile() throws IOException {
158-
when(remoteMetadataDirectory.listFilesByPrefixInLexicographicOrder(RemoteSegmentStoreDirectory.MetadataFilenameUtils.METADATA_PREFIX, METADATA_FILES_TO_FETCH)).thenReturn(
159-
List.of(metadataFilename, metadataFilenameDup)
160-
);
161+
when(
162+
remoteMetadataDirectory.listFilesByPrefixInLexicographicOrder(
163+
RemoteSegmentStoreDirectory.MetadataFilenameUtils.METADATA_PREFIX,
164+
METADATA_FILES_TO_FETCH
165+
)
166+
).thenReturn(List.of(metadataFilename, metadataFilenameDup));
161167
assertThrows(IllegalStateException.class, () -> remoteSegmentStoreDirectory.init());
162168
}
163169

0 commit comments

Comments
 (0)