Skip to content

Commit 26e39d2

Browse files
authored
Merge pull request #5665 from dizzzz/feature/more_syntaxchanges_2
[refactor] revise Java code to newer java language levels
2 parents 0cface9 + d53fbaf commit 26e39d2

File tree

15 files changed

+34
-40
lines changed

15 files changed

+34
-40
lines changed

exist-core/src/test/java/org/exist/collections/triggers/TestTrigger.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ private void addRecord(DBBroker broker, Txn transaction, String xupdate) throws
8686
XUpdateProcessor processor = new XUpdateProcessor(broker, docs);
8787
// process the XUpdate
8888
Modification modifications[] = processor.parse(new InputSource(new StringReader(xupdate)));
89-
for (int i = 0; i < modifications.length; i++) {
90-
modifications[i].process(transaction);
89+
for (Modification modification : modifications) {
90+
modification.process(transaction);
9191
}
9292

9393
broker.flush();

exist-core/src/test/java/org/exist/deadlocks/GetReleaseBrokerDeadlocks.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ public void testingGetReleaseCycle() {
134134
sb.append("THREAD: ");
135135
sb.append(entry.getKey().getName());
136136
sb.append("\n");
137-
for (int n = 0; n < stacks.length; n++) {
138-
sb.append(" ");
139-
sb.append(stacks[n]);
140-
sb.append("\n");
141-
}
137+
for (StackTraceElement stack : stacks) {
138+
sb.append(" ");
139+
sb.append(stack);
140+
sb.append("\n");
141+
}
142142
}
143143

144144
if (stackTraces.isEmpty())

exist-core/src/test/java/org/exist/storage/NodePathTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,7 @@ public void equalsAfterResetAndAddComponent() throws QName.IllegalQNameException
367367

368368
private void addComponents(final NodePath destination, final String path) throws QName.IllegalQNameException {
369369
final String[] components = path.split("/");
370-
for (int i = 0; i < components.length; i++) {
371-
final String component = components[i];
370+
for (final String component : components) {
372371
if (!component.isEmpty()) {
373372
destination.addComponent(new QName(component));
374373
}

exist-core/src/test/java/org/exist/util/hashtable/SequencedLongHashMapTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ public void sequencedMap2() {
7272

7373
final SequencedLongHashMap<String> map = new SequencedLongHashMap<>();
7474

75-
for (int i = 0; i < l.length; i++) {
76-
map.put(l[i], "k" + l[i]);
77-
}
75+
for (long value : l) {
76+
map.put(value, "k" + value);
77+
}
7878

7979
map.removeFirst();
8080
final Iterator<Long2ObjectMap.Entry<String>> entries = map.fastEntrySetIterator();

exist-core/src/test/java/org/exist/util/io/ByteBufferInputStreamTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ public void readByteByByteCorrectAndThenReturnMinus1AtEndOfStream() throws IOExc
8181

8282
InputStream is = new ByteBufferInputStream(new TestableByteBufferAccessor(buf));
8383

84-
for(int i = 0; i < testData.length; i++) {
85-
assertEquals(testData[i], is.read());
84+
for (byte testDatum : testData) {
85+
assertEquals(testDatum, is.read());
8686
}
8787

8888
//ensure reading past the end of the stream returns -1

exist-core/src/test/java/org/exist/util/sorters/ListChecker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ int getLength() {
7070
*/
7171
void init(int[] values) throws Exception {
7272
a = new ArrayList<Integer>(values.length);
73-
for (int i = 0; i < values.length; i++) {
74-
a.add(Integer.valueOf(values[i]));
75-
}
73+
for (int value : values) {
74+
a.add(Integer.valueOf(value));
75+
}
7676
}
7777

7878
/**

exist-core/src/test/java/org/exist/xmlrpc/QuerySessionTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ public static void startServer() throws ClassNotFoundException, IllegalAccessExc
158158

159159
final TestDataGenerator generator = new TestDataGenerator("xdb", DOC_COUNT);
160160
final Path[] files = generator.generate(test, generateXQ);
161-
for (int i = 0; i < files.length; i++) {
162-
Resource resource = test.createResource(files[i].getFileName().toString(), XMLResource.class);
163-
resource.setContent(files[i].toFile());
161+
for (Path file : files) {
162+
Resource resource = test.createResource(file.getFileName().toString(), XMLResource.class);
163+
resource.setContent(file.toFile());
164164
test.storeResource(resource);
165165
}
166166
generator.releaseAll();

exist-core/src/test/java/org/exist/xmlrpc/XmlRpcTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,8 @@ public void testCollectionWithAccentsAndSpaces() throws XmlRpcException, Malform
652652
Object[] collections = (Object[]) collection.get("collections");
653653
boolean foundMatch = false;
654654
String targetCollectionName = SPECIAL_COLLECTION.lastSegment().toString();
655-
for (int i = 0; i < collections.length; i++) {
656-
String childName = (String) collections[i];
655+
for (Object o : collections) {
656+
String childName = (String) o;
657657
if (childName.equals(targetCollectionName)) {
658658
foundMatch = true;
659659
break;

exist-core/src/test/java/org/exist/xquery/StoredModuleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ public void testQuery() throws Exception {
103103
xqService.setNamespace("itg-modules", "http://localhost:80/itg/xquery");
104104

105105
CompiledExpression compiledQuery = xqService.compile(query);
106-
for (int i = 0; i < cols.length; i++) {
107-
xqService.declareVariable("itg-modules:coll", cols[i]);
106+
for (String col : cols) {
107+
xqService.declareVariable("itg-modules:coll", col);
108108
ResourceSet result = xqService.execute(compiledQuery);
109109
result.getResource(0).getContent();
110110
}

exist-core/src/test/java/org/exist/xquery/value/MockBinaryValueManager.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ public void registerBinaryValueInstance(final BinaryValue binaryValue) {
4444
public void runCleanupTasks(final Predicate<Object> predicate) {
4545
if (values != null) {
4646
List<BinaryValue> removable = null;
47-
for(final Iterator<BinaryValue> iterator = values.iterator(); iterator.hasNext();) {
48-
final BinaryValue bv = iterator.next();
47+
for (final BinaryValue bv : values) {
4948
try {
5049
if (predicate.test(bv)) {
5150
bv.close();
52-
if(removable == null) {
51+
if (removable == null) {
5352
removable = new ArrayList<>();
5453
}
5554
removable.add(bv);

0 commit comments

Comments
 (0)