Skip to content

Commit e5dc57f

Browse files
committed
Fix build for newer Java
1 parent 39dd940 commit e5dc57f

File tree

66 files changed

+352
-316
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+352
-316
lines changed

modules/accumulo/src/main/java/org/apache/fluo/accumulo/values/LockValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/**
2828
*
2929
*/
30-
public class LockValue {
30+
public final class LockValue {
3131

3232
private final Bytes prow;
3333
private final Column pcol;

modules/accumulo/src/main/java/org/apache/fluo/accumulo/values/ReadLockValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import static org.apache.fluo.accumulo.format.FluoFormatter.encNonAscii;
2626

27-
public class ReadLockValue {
27+
public final class ReadLockValue {
2828
private final Bytes prow;
2929
private final Column pcol;
3030
private final Long transactor;

modules/accumulo/src/test/java/org/apache/fluo/accumulo/iterators/TestData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import org.apache.fluo.api.data.Bytes;
3939
import org.apache.fluo.api.data.Column;
4040

41-
public class TestData {
41+
public final class TestData {
4242
TreeMap<Key, Value> data = new TreeMap<>();
4343
Counter counter = new Counter();
4444

modules/accumulo/src/test/java/org/apache/fluo/accumulo/util/LongUtilTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
55
* "License"); you may not use this file except in compliance with the License. You may obtain a
66
* copy of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software distributed under the License
1111
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
1212
* or implied. See the License for the specific language governing permissions and limitations under
@@ -25,14 +25,14 @@ public class LongUtilTest {
2525

2626
@Test
2727
public void testAll() {
28-
Long longVal = new Long("34886");
28+
Long longVal = Long.parseLong("34886");
2929
String radixStr = LongUtil.toMaxRadixString(longVal);
3030
Assert.assertEquals("qx2", radixStr);
3131
Assert.assertEquals(longVal, LongUtil.fromMaxRadixString(radixStr));
3232
Assert.assertEquals(longVal,
3333
LongUtil.fromMaxRadixByteArray(LongUtil.toMaxRadixByteArray(longVal)));
3434

35-
longVal = new Long("63832");
35+
longVal = Long.parseLong("63832");
3636
Assert.assertEquals(longVal, LongUtil.fromByteArray(LongUtil.toByteArray(longVal)));
3737
}
3838
}

modules/api/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
<plugin>
9292
<groupId>net.revelc.code</groupId>
9393
<artifactId>apilyzer-maven-plugin</artifactId>
94-
<version>1.0.1</version>
9594
<executions>
9695
<execution>
9796
<id>apilyzer</id>

modules/api/src/main/java/org/apache/fluo/api/client/Snapshot.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
package org.apache.fluo.api.client;
1717

18-
import java.util.Collection;
19-
2018
/**
2119
* Allows users to read from a Fluo table at a certain point in time. Snapshot extends
2220
* {@link SnapshotBase} to include a {@link #close} method which must be called when you are

modules/api/src/main/java/org/apache/fluo/api/config/SimpleConfiguration.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
55
* "License"); you may not use this file except in compliance with the License. You may obtain a
66
* copy of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software distributed under the License
1111
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
1212
* or implied. See the License for the specific language governing permissions and limitations under
@@ -177,7 +177,7 @@ public String getString(String key, String defaultValue) {
177177

178178
/**
179179
* Loads configuration from InputStream. Later loads have lower priority.
180-
*
180+
*
181181
* @param in InputStream to load from
182182
* @since 1.2.0
183183
*/
@@ -193,7 +193,7 @@ public void load(InputStream in) {
193193

194194
/**
195195
* Loads configuration from File. Later loads have lower priority.
196-
*
196+
*
197197
* @param file File to load from
198198
* @since 1.2.0
199199
*/
@@ -262,6 +262,7 @@ public void setProperties(String key, String... values) {
262262
*/
263263
public String[] getProperties(String key) {
264264
// TODO fix cast class; use Properties?
265+
@SuppressWarnings("unchecked")
265266
ArrayList<String> values = (ArrayList<String>) internalConfig.getProperty(key);
266267
if (values == null) {
267268
return new String[0];
@@ -283,7 +284,7 @@ public SimpleConfiguration subset(String prefix) {
283284
* @param fallback SimpleConfiguration to join together
284285
* @return a new simple configuration that contains all of the current properties from this plus
285286
* the properties from fallback that are not present in this.
286-
*
287+
*
287288
* @since 1.2.0
288289
*/
289290
public SimpleConfiguration orElse(SimpleConfiguration fallback) {
@@ -374,7 +375,7 @@ private String stream2String(InputStream in) {
374375
result.write(buffer, 0, length);
375376
}
376377

377-
return result.toString(UTF_8.name());
378+
return result.toString(UTF_8);
378379
} catch (IOException e) {
379380
throw new UncheckedIOException(e);
380381
}
@@ -397,4 +398,11 @@ private Reader checkProps(InputStream in) {
397398

398399
return new StringReader(propsData);
399400
}
401+
402+
// CHECKSTYLE:OFF: NoFinalizer
403+
@Override
404+
public final void finalize() {
405+
// prevent CT_CONSTRUCTOR_THROW spotbugs warning about finalizer attacks
406+
}
407+
// CHECKSTYLE:ON: NoFinalizer
400408
}

modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ public BytesBuilder append(CharSequence cs) {
512512
return append((String) cs);
513513
}
514514

515-
516515
ByteBuffer bb = StandardCharsets.UTF_8.encode(CharBuffer.wrap(cs));
517516

518517
int length = bb.remaining();
@@ -582,7 +581,9 @@ public BytesBuilder append(byte[] bytes, int offset, int length) {
582581
*/
583582
public BytesBuilder append(InputStream in, int length) throws IOException {
584583
ensureCapacity(len + length);
585-
new DataInputStream(in).readFully(ba, len, length);
584+
// create an anonymous subclass of DataInputStream to avoid unclosed resource warnings
585+
// we don't close it because we don't want to close the provided InputStream it is wrapping
586+
new DataInputStream(in) {}.readFully(ba, len, length);
586587
len += length;
587588
return this;
588589
}

modules/api/src/test/java/org/apache/fluo/api/config/FluoConfigurationTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
import java.io.ByteArrayInputStream;
1919
import java.io.ByteArrayOutputStream;
20-
import java.io.File;
2120
import java.io.ObjectInputStream;
2221
import java.io.ObjectOutputStream;
2322
import java.lang.reflect.InvocationTargetException;
23+
import java.nio.file.Path;
2424
import java.util.Arrays;
2525
import java.util.HashSet;
2626
import java.util.List;
@@ -175,9 +175,9 @@ public void testHasMiniFluoProps() {
175175

176176
@Test
177177
public void testLoadingDistPropsFile() {
178-
File connectionProps = new File("../distribution/src/main/config/fluo-conn.properties");
178+
var connectionProps = Path.of("../distribution/src/main/config/fluo-conn.properties").toFile();
179179
Assert.assertTrue(connectionProps.exists());
180-
File applicationProps = new File("../distribution/src/main/config/fluo-app.properties");
180+
var applicationProps = Path.of("../distribution/src/main/config/fluo-app.properties").toFile();
181181
Assert.assertTrue(applicationProps.exists());
182182

183183
FluoConfiguration config = new FluoConfiguration(connectionProps);
@@ -211,7 +211,7 @@ public void testLoadingDistPropsFile() {
211211

212212
@Test
213213
public void testLoadingOldTestPropsFile() {
214-
File propsFile = new File("src/test/resources/fluo.properties");
214+
var propsFile = Path.of("src/test/resources/fluo.properties").toFile();
215215
Assert.assertTrue(propsFile.exists());
216216

217217
FluoConfiguration config = new FluoConfiguration(propsFile);
@@ -233,7 +233,7 @@ public void testLoadingOldTestPropsFile() {
233233

234234
@Test
235235
public void testLoadingTestPropsFile() {
236-
File applicationProps = new File("src/test/resources/fluo-app.properties");
236+
var applicationProps = Path.of("src/test/resources/fluo-app.properties").toFile();
237237
Assert.assertTrue(applicationProps.exists());
238238

239239
FluoConfiguration config = new FluoConfiguration(applicationProps);
@@ -251,7 +251,7 @@ public void testLoadingTestPropsFile() {
251251
Assert.assertEquals(30000, config.getZookeeperTimeout());
252252
Assert.assertEquals(-1, config.getConnectionRetryTimeout());
253253

254-
File connectionProps = new File("src/test/resources/fluo-conn.properties");
254+
var connectionProps = Path.of("src/test/resources/fluo-conn.properties").toFile();
255255
Assert.assertTrue(applicationProps.exists());
256256
config.load(connectionProps);
257257
Assert.assertEquals("localhost/test-fluo", config.getInstanceZookeepers());

modules/api/src/test/java/org/apache/fluo/api/data/ColumnTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.apache.fluo.api.data;
1717

1818
import java.util.Arrays;
19-
import java.util.List;
2019

2120
import org.junit.Assert;
2221
import org.junit.Test;

0 commit comments

Comments
 (0)