Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on deprecated #862

Merged
merged 9 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>net.openhft</groupId>
<artifactId>java-parent-pom</artifactId>
<version>1.25.4</version>
<relativePath />
<relativePath/>
</parent>

<artifactId>chronicle-wire</artifactId>
Expand All @@ -32,10 +33,6 @@
<description>Chronicle-Wire</description>
<packaging>bundle</packaging>
<properties>
<argLine />
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<compiler.argument>-Xlint:deprecation</compiler.argument>
<sonar.organization>openhft</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<!-- The parent POM defines this plugin and activates it in a profile. Unfortunately this plugin will generate
Expand Down Expand Up @@ -243,12 +240,13 @@
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-Xlint:deprecation</arg>
<arg>-Xlint:deprecation,-options</arg>
<arg>-parameters</arg>
</compilerArgs>
<source>1.8</source>
<target>1.8</target>
<source>8</source>
<target>8</target>
<encoding>UTF-8</encoding>
<failOnWarning>true</failOnWarning>
</configuration>
</plugin>
<!--
Expand Down Expand Up @@ -450,6 +448,15 @@
</scm>

<profiles>
<profile>
<id>java11-release8</id>
peter-lawrey marked this conversation as resolved.
Show resolved Hide resolved
<activation>
<jdk>[11,</jdk>
</activation>
<properties>
<maven.compiler.release>8</maven.compiler.release>
</properties>
</profile>
<profile>
<id>sonar</id>
<build>
Expand Down Expand Up @@ -519,7 +526,9 @@
</goals>
<configuration>
<executable>${java.home}/bin/java</executable>
<commandlineArgs>${jvm.requiredArgs} -classpath %classpath net.openhft.chronicle.wire.AbstractTimestampLongConverterJLBHBenchmark</commandlineArgs>
<commandlineArgs>${jvm.requiredArgs} -classpath %classpath
net.openhft.chronicle.wire.AbstractTimestampLongConverterJLBHBenchmark
</commandlineArgs>
</configuration>
</execution>
</executions>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/openhft/chronicle/wire/AbstractWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public abstract class AbstractWire implements Wire {
private HeadNumberChecker headNumberChecker;
private boolean usePadding = DEFAULT_USE_PADDING;

@SuppressWarnings("rawtypes")
protected AbstractWire(@NotNull Bytes<?> bytes, boolean use8bit) {
this.bytes = bytes;
this.use8bit = use8bit;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/openhft/chronicle/wire/BinaryWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
import static net.openhft.chronicle.core.util.ReadResolvable.readResolve;
import static net.openhft.chronicle.wire.BinaryWire.AnyCodeMatch.ANY_CODE_MATCH;
import static net.openhft.chronicle.wire.BinaryWireCode.*;
import static net.openhft.chronicle.wire.Wires.GENERATE_TUPLES;
import static net.openhft.chronicle.wire.Wires.THROW_CNFRE;
import static net.openhft.chronicle.wire.Wires.*;

/**
* This Wire is a binary translation of TextWire which is a sub set of YAML.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public boolean isMetaData() {
}

@Override
@SuppressWarnings("rawtypes")
public void close() {
if (chainedElement)
return;
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/net/openhft/chronicle/wire/CSVWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class CSVWire extends TextWire {

private final List<String> header = new ArrayList<>();

@SuppressWarnings("rawtypes")
public CSVWire(@NotNull Bytes<?> bytes, boolean use8bit) {
super(bytes, use8bit);
while (lineStart == 0) {
Expand All @@ -48,7 +47,6 @@ public CSVWire(@NotNull Bytes<?> bytes, boolean use8bit) {
}
}

@SuppressWarnings("rawtypes")
public CSVWire(@NotNull Bytes<?> bytes) {
this(bytes, false);
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/openhft/chronicle/wire/FieldInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ static Wires.FieldInfoPair lookupClass(@NotNull Class<?> aClass) {
* @return a {@link Class} identifying the declared type of the field
* represented by this {@code FieldInfo} object.
*/
@SuppressWarnings("rawtypes")
Class<?> type();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import static net.openhft.chronicle.core.util.GenericReflection.erase;
import static net.openhft.chronicle.core.util.GenericReflection.getParameterTypes;

@SuppressWarnings("StringBufferReplaceableByString")
public class GenerateMethodWriter {

public static final String UPDATE_INTERCEPTOR = UpdateInterceptor.class.getSimpleName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import static java.util.Arrays.stream;
import static java.util.Collections.*;

@SuppressWarnings("StringBufferReplaceableByString")
public class GenerateMethodWriter2 extends AbstractClassGenerator<GenerateMethodWriter2.GMWMetaData> {

private static final String DOCUMENT_CONTEXT = DocumentContext.class.getSimpleName();
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/net/openhft/chronicle/wire/JSONWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public class JSONWire extends TextWire {
static final Supplier<StopCharsTester> STRICT_END_OF_TEXT_JSON_ESCAPING = TextStopCharsTesters.STRICT_END_OF_TEXT_JSON::escaping;
boolean useTypes;

@SuppressWarnings("rawtypes")
public JSONWire() {
this(Bytes.allocateElasticOnHeap());
}
Expand All @@ -68,7 +67,6 @@ public JSONWire(@NotNull Bytes<?> bytes, boolean use8bit) {
trimFirstCurly(false);
}

@SuppressWarnings("rawtypes")
public JSONWire(@NotNull Bytes<?> bytes) {
this(bytes, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.jetbrains.annotations.NotNull;

public interface KeyedMarshallable {
@SuppressWarnings("rawtypes")
default void writeKey(@NotNull Bytes<?> bytes) {
Wires.writeKey(this, bytes);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/openhft/chronicle/wire/LongValueBitSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void setWord(int wordIndex, long bits) {

@Override
protected void performClose() {
closeQuietly(words);
closeQuietly((Object[]) words);
}

public int getWordsInUse() {
Expand Down Expand Up @@ -796,7 +796,7 @@ public void readMarshallable(@NotNull final WireIn wire) throws IORuntimeExcepti
singleThreadedCheckDisabled(true);
throwExceptionIfClosed();

closeQuietly(words);
closeQuietly((Object[]) words);

int numberOfLongValues = wire.read("numberOfLongValues").int32();
words = new LongReference[numberOfLongValues];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ default boolean readBytes(@NotNull ReadBytesMarshallable reader) throws InvalidM
* @param using used to read the document
* @return {@code true} if successful
*/
@SuppressWarnings("rawtypes")
default boolean readBytes(@NotNull Bytes<?> using) throws InvalidMarshallableException {
try (@NotNull DocumentContext dc = readingDocument()) {
if (!dc.isPresent())
Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/openhft/chronicle/wire/ReadAnyWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
*
* @author Rob Austin.
*/
@SuppressWarnings("rawtypes")
public class ReadAnyWire extends AbstractAnyWire implements Wire {

public ReadAnyWire(@NotNull Bytes<?> bytes) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/openhft/chronicle/wire/TextWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static net.openhft.chronicle.bytes.NativeBytes.nativeBytes;
import static net.openhft.chronicle.wire.TextStopCharTesters.END_OF_TYPE;
import static net.openhft.chronicle.wire.Wires.GENERATE_TUPLES;
import static net.openhft.chronicle.wire.Wires.THROW_CNFRE;
import static net.openhft.chronicle.wire.Wires.*;

/**
* YAML Based wire format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public boolean isMetaData() {
}

@Override
@SuppressWarnings("rawtypes")
public void close() {
if (chainedElement)
return;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/openhft/chronicle/wire/ValueOut.java
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ default WireOut writeLong(LongConverter longConverter, long l) {
try (ScopedResource<StringBuilder> stlSb = Wires.acquireStringBuilderScoped()) {
StringBuilder sb = stlSb.get();
longConverter.append(sb, l);
if (longConverter.allSafeChars(wireOut()) && sb.length() > 0)
if (longConverter.allSafeChars() && sb.length() > 0)
return rawText(sb);
else
return text(sb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
* The {@code VanillaMessageHistory} class is an implementation of {@link MessageHistory} that
* provides an array-backed history of messages.
*/
@SuppressWarnings("rawtypes")
public class VanillaMessageHistory extends SelfDescribingMarshallable implements MessageHistory {

// Maximum length for storing message history
Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/openhft/chronicle/wire/WireDumper.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@SuppressWarnings("rawtypes")
public class WireDumper {
@NotNull
private final WireIn wireIn;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/openhft/chronicle/wire/WireInternal.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import static net.openhft.chronicle.core.pool.ClassAliasPool.CLASS_ALIASES;
import static net.openhft.chronicle.wire.Wires.toIntU30;

@SuppressWarnings({"rawtypes", "unchecked"})
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"})
public enum WireInternal {
; // none
static final StringInterner INTERNER = new StringInterner(Jvm.getInteger("wire.interner.size", 4096));
Expand Down Expand Up @@ -311,7 +311,6 @@ protected static Throwable throwable(@NotNull ValueIn valueIn, boolean appendCur
stes.add(stes2[i]);
}
try {
//noinspection ToArrayCallWithZeroLengthArrayArgument
STACK_TRACE.set(finalThrowable, stes.toArray(NO_STE));
} catch (IllegalAccessException e) {
throw Jvm.rethrow(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ public static Object create(@NotNull Field field, @Nullable Object defaultObject
boolean isLeaf = !Throwable.class.isAssignableFrom(componentType)
&& WIRE_MARSHALLER_CL.get(componentType).isLeaf;
try {
Object[] values = (Object[]) Jvm.getMethod(componentType, "values").invoke(componentType, null);
Object[] values = (Object[]) Jvm.getMethod(componentType, "values").invoke(componentType);
return new EnumSetFieldAccess(field, isLeaf, values, componentType);
} catch (IllegalAccessException | InvocationTargetException e) {
throw Jvm.rethrow(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public int read(@NotNull byte[] b) throws IOException {
return read(b, 0, b.length);
}

@SuppressWarnings("rawtypes")
@Override
public int read(@NotNull byte[] b, int off, int len) throws IOException {
final long remaining = wire.bytes().readRemaining();
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/openhft/chronicle/wire/Wires.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ public enum Wires {
public static final int SPB_HEADER_SIZE = 4;
public static final List<Function<Class, SerializationStrategy>> CLASS_STRATEGY_FUNCTIONS = new CopyOnWriteArrayList<>();

@Deprecated(/* for removal in x.26 */)
// Adding SuppressWarnings on every usage could have too many side effects, so make it a comment for now, but still remove it.
// @Deprecated(/* for removal in x.26 */)
peter-lawrey marked this conversation as resolved.
Show resolved Hide resolved
static boolean THROW_CNFRE = Jvm.getBoolean("class.not.found.for.missing.class.alias", true);

static final ClassLocal<SerializationStrategy> CLASS_STRATEGY = ClassLocal.withInitial(c -> {
for (@NotNull Function<Class, SerializationStrategy> func : CLASS_STRATEGY_FUNCTIONS) {
final SerializationStrategy strategy = func.apply(c);
Expand Down Expand Up @@ -1024,7 +1026,6 @@ public SerializationStrategy apply(@NotNull Class aClass) {

case "java.lang.Character":
return ScalarStrategy.of(Character.class, (o, in) -> {
//noinspection unchecked
@Nullable final String text = in.text();
if (text == null || text.length() == 0)
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public Set<HostPortCfg> hostPorts() {
* @param port the port number
* @return this configuration instance
*/
public ChronicleChannelCfg<C> addHostnamePort(String hostname, int port) {
public C addHostnamePort(String hostname, int port) {
peter-lawrey marked this conversation as resolved.
Show resolved Hide resolved
hostports.add(new HostPortCfg(hostname, port));
return this;
return (C) this;
}

/**
Expand All @@ -95,9 +95,9 @@ public void removeHostnamePort(String hostname, int port) {
* @param initiator the initiator flag
* @return this configuration instance
*/
public ChronicleChannelCfg<C> initiator(boolean initiator) {
public C initiator(boolean initiator) {
this.initiator = initiator;
return this;
return (C) this;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ public ChronicleChannelSupplier newChannelSupplier(ChannelHandler handler) throw

connectionSupplier
.protocol(url().getProtocol())
.hostname(hostname == null || hostname.isEmpty() ? "localhost" : hostname)
.port(port)
.addHostnamePort(hostname == null || hostname.isEmpty() ? "localhost" : hostname, port)
peter-lawrey marked this conversation as resolved.
Show resolved Hide resolved
.connectionId(connectionId)
.buffered(buffered())
.initiator(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void run() {
Throwable thrown = null;
try {
bindSSC();
ChronicleChannelCfg channelCfg = new ChronicleChannelCfg().port(url().getPort()).pauserMode(pauserMode).buffered(buffered);
ChronicleChannelCfg channelCfg = new ChronicleChannelCfg().addHostnamePort(null, url().getPort()).pauserMode(pauserMode).buffered(buffered);
while (!isClosed()) {
final SocketChannel sc = ssc.accept();
sc.socket().setTcpNoDelay(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void run() {
try {
ssc = ServerSocketChannel.open();
ssc.bind(new InetSocketAddress(port));
ChronicleChannelCfg channelCfg = new ChronicleChannelCfg().port(port);
ChronicleChannelCfg channelCfg = new ChronicleChannelCfg().addHostnamePort(null, port);
Function<ChannelHeader, ChannelHeader> redirectFunction = this::replaceOutHeader;
while (!isClosed()) {
final SocketChannel sc = ssc.accept();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public static ChronicleChannel newChannel(SocketRegistry socketRegistry,
for (String location : rh.locations()) {
try {
URL url = ChronicleContext.urlFor(location);
channelCfg.hostname(url.getHost());
channelCfg.port(url.getPort());
channelCfg.addHostnamePort(url.getHost(), url.getPort());
return newChannel(socketRegistry, channelCfg, headerOut,null);

} catch (IORuntimeException e) {
Expand All @@ -60,7 +59,7 @@ public static ChronicleChannel newChannel(SocketRegistry socketRegistry, Chronic

@NotNull
public static Runnable eventHandlerAsRunnable(ChronicleChannel chronicleChannel, Object eventHandler) {
@SuppressWarnings("resource") final MethodReader reader = chronicleChannel.methodReader(eventHandler);
final MethodReader reader = chronicleChannel.methodReader(eventHandler);
final BooleanSupplier handlerClosed;
if (eventHandler instanceof Closeable) {
Closeable sh = (Closeable) eventHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*
* @author peter.lawrey
*/
@SuppressWarnings({"rawtypes", "unchecked"})
@SuppressWarnings({"unchecked"})
public abstract class FromStringInterner<T> {
protected final InternerEntry<T>[] entries;
protected final int mask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@

import net.openhft.chronicle.core.UnsafeMemory;
import net.openhft.chronicle.wire.BracketType;
import net.openhft.chronicle.wire.VanillaFieldInfo;
import org.jetbrains.annotations.NotNull;

import java.lang.reflect.Field;

@SuppressWarnings("deprecation" /* The parent class will either be moved to internal or cease to exist in x.26 */)
class UnsafeFieldInfo extends VanillaFieldInfo {
class UnsafeFieldInfo extends net.openhft.chronicle.wire.VanillaFieldInfo {
private static final long UNSET_OFFSET = Long.MAX_VALUE;
private transient long offset = UNSET_OFFSET;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class BinaryToTextTest extends WireTestCommon {

@Test
public void test() {
@SuppressWarnings("rawtypes")
Bytes<?> tbytes = Bytes.allocateElasticOnHeap();
@NotNull Wire tw = new BinaryWire(tbytes);
tw.usePadding(true);
Expand Down
Loading