Skip to content

Commit 1f8432c

Browse files
committed
Take care of some deprecated warnings
(cherry picked from commit 177eb3f)
1 parent 0369b9e commit 1f8432c

File tree

4 files changed

+29
-24
lines changed

4 files changed

+29
-24
lines changed

src/main/java/com/rabbitmq/jms/client/RMQMessage.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,13 +1061,17 @@ private static RMQMessage instantiateRmqMessage(String messageClass, List<String
10611061
} else {
10621062
try {
10631063
// instantiate the message object with the thread context classloader
1064-
return (RMQMessage) Class.forName(messageClass, true, Thread.currentThread().getContextClassLoader()).newInstance();
1064+
return (RMQMessage) Class.forName(messageClass, true, Thread.currentThread().getContextClassLoader()).getDeclaredConstructor().newInstance();
10651065
} catch (InstantiationException e) {
10661066
throw new RMQJMSException(e);
10671067
} catch (IllegalAccessException e) {
10681068
throw new RMQJMSException(e);
10691069
} catch (ClassNotFoundException e) {
10701070
throw new RMQJMSException(e);
1071+
} catch (NoSuchMethodException e) {
1072+
throw new RMQJMSException(e);
1073+
} catch (InvocationTargetException e) {
1074+
throw new RMQJMSException(e);
10711075
}
10721076
}
10731077
}

src/main/java/com/rabbitmq/jms/parse/sql/SqlEvaluatorVisitor.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ private static final Boolean like(Object o1, Object o2) {
128128
private static final Object add(Object o1, Object o2) {
129129
if (isLong(o1)) {
130130
if (isLong(o2)) return toLong(o1) + toLong(o2);
131-
else if(isDouble(o2)) return new Double(o1.toString()) + toDouble(o2);
131+
else if(isDouble(o2)) return Double.valueOf(o1.toString()) + toDouble(o2);
132132
else return null;
133133
} else if (isDouble(o1)) {
134134
if (isDouble(o2)) return toDouble(o1) + toDouble(o2);
135-
else if (isLong(o2)) return toDouble(o1) + new Double(o2.toString());
135+
else if (isLong(o2)) return toDouble(o1) + Double.valueOf(o2.toString());
136136
else return null;
137137
}
138138
return null;
@@ -158,11 +158,11 @@ private static final double toDouble(Object o) {
158158
private static final Object subtract(Object o1, Object o2) {
159159
if (isLong(o1)) {
160160
if (isLong(o2)) return toLong(o1) - toLong(o2);
161-
else if(isDouble(o2)) return new Double(o1.toString()) - toDouble(o2);
161+
else if(isDouble(o2)) return Double.valueOf(o1.toString()) - toDouble(o2);
162162
else return null;
163163
} else if (isDouble(o1)) {
164164
if (isDouble(o2)) return toDouble(o1) - toDouble(o2);
165-
else if (isLong(o2)) return toDouble(o1) - new Double(o2.toString());
165+
else if (isLong(o2)) return toDouble(o1) - Double.valueOf(o2.toString());
166166
else return null;
167167
}
168168
return null;
@@ -171,11 +171,11 @@ private static final Object subtract(Object o1, Object o2) {
171171
private static final Object multiply(Object o1, Object o2) {
172172
if (isLong(o1)) {
173173
if (isLong(o2)) return toLong(o1) * toLong(o2);
174-
else if(isDouble(o2)) return new Double(o1.toString()) * toDouble(o2);
174+
else if(isDouble(o2)) return Double.valueOf(o1.toString()) * toDouble(o2);
175175
else return null;
176176
} else if (isDouble(o1)) {
177177
if (isDouble(o2)) return toDouble(o1) * toDouble(o2);
178-
else if (isLong(o2)) return toDouble(o1) * new Double(o2.toString());
178+
else if (isLong(o2)) return toDouble(o1) * Double.valueOf(o2.toString());
179179
else return null;
180180
}
181181
return null;
@@ -184,11 +184,11 @@ private static final Object multiply(Object o1, Object o2) {
184184
private static final Object divide(Object o1, Object o2) {
185185
if (isLong(o1)) {
186186
if (isLong(o2)) return toLong(o1) / toLong(o2);
187-
else if(isDouble(o2)) return new Double(o1.toString()) / toDouble(o2);
187+
else if(isDouble(o2)) return Double.valueOf(o1.toString()) / toDouble(o2);
188188
else return null;
189189
} else if (isDouble(o1)) {
190190
if (isDouble(o2)) return toDouble(o1) / toDouble(o2);
191-
else if (isLong(o2)) return toDouble(o1) / new Double(o2.toString());
191+
else if (isLong(o2)) return toDouble(o1) / Double.valueOf(o2.toString());
192192
else return null;
193193
}
194194
return null;
@@ -205,11 +205,11 @@ private static final Boolean in(Object o1, Object o2) {
205205
private static final Boolean greaterThan(Object o1, Object o2) {
206206
if (isLong(o1)) {
207207
if (isLong(o2)) return toLong(o1) > toLong(o2);
208-
else if(isDouble(o2)) return new Double(o1.toString()) > toDouble(o2);
208+
else if(isDouble(o2)) return Double.valueOf(o1.toString()) > toDouble(o2);
209209
else return null;
210210
} else if (isDouble(o1)) {
211211
if (isDouble(o2)) return toDouble(o1) > toDouble(o2);
212-
else if (isLong(o2)) return toDouble(o1) > new Double(o2.toString());
212+
else if (isLong(o2)) return toDouble(o1) > Double.valueOf(o2.toString());
213213
else return null;
214214
}
215215
return null;

src/main/java/com/rabbitmq/jms/util/RMQByteArrayOutputStream.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2013 Pivotal Software, Inc. All rights reserved. */
1+
/* Copyright (c) 2013-2018 Pivotal Software, Inc. All rights reserved. */
22
package com.rabbitmq.jms.util;
33

44
import java.io.ByteArrayOutputStream;
@@ -13,32 +13,32 @@ public RMQByteArrayOutputStream(int size) {
1313
super(size);
1414
}
1515

16-
public void writeBoolean(boolean value) throws JMSException {
16+
public void writeBoolean(boolean value) {
1717
this.write((byte) (value ? 1 : 0));
1818
}
1919

20-
public void writeByte(byte value) throws JMSException {
20+
public void writeByte(byte value) {
2121
this.write(value);
2222
}
2323

24-
public void writeShort(short value) throws JMSException {
24+
public void writeShort(short value) {
2525
this.write((byte) (value >>> 8));
2626
this.write((byte) (value >>> 0));
2727
}
2828

29-
public void writeChar(char value) throws JMSException {
29+
public void writeChar(char value) {
3030
this.write((byte) (value >>> 8));
3131
this.write((byte) (value >>> 0));
3232
}
3333

34-
public void writeInt(int value) throws JMSException {
34+
public void writeInt(int value) {
3535
this.write((byte) (value >>> 24));
3636
this.write((byte) (value >>> 16));
3737
this.write((byte) (value >>> 8));
3838
this.write((byte) (value >>> 0));
3939
}
4040

41-
public void writeLong(long value) throws JMSException {
41+
public void writeLong(long value) {
4242
this.write((byte) (value >>> 56));
4343
this.write((byte) (value >>> 48));
4444
this.write((byte) (value >>> 40));
@@ -49,11 +49,11 @@ public void writeLong(long value) throws JMSException {
4949
this.write((byte) (value >>> 0));
5050
}
5151

52-
public void writeFloat(float value) throws JMSException {
52+
public void writeFloat(float value) {
5353
this.writeInt(Float.floatToIntBits(value));
5454
}
5555

56-
public void writeDouble(double value) throws JMSException {
56+
public void writeDouble(double value) {
5757
this.writeLong(Double.doubleToLongBits(value));
5858
}
5959

@@ -69,15 +69,15 @@ public void writeUTF(String value) throws JMSException {
6969
}
7070
}
7171

72-
public void writeBytes(byte[] value) throws JMSException {
72+
public void writeBytes(byte[] value) {
7373
if (value == null)
74-
throw new MessageFormatException("Null byte array");
74+
throw new IllegalArgumentException("Null byte array");
7575
this.writeBytes(value, 0, value.length);
7676
}
7777

78-
public void writeBytes(byte[] value, int offset, int length) throws JMSException {
78+
public void writeBytes(byte[] value, int offset, int length) {
7979
if (value == null) {
80-
throw new MessageFormatException("Null byte array");
80+
throw new IllegalArgumentException("Null byte array");
8181
} else if (offset>=value.length || length<0) {
8282
throw new IndexOutOfBoundsException();
8383
}

src/main/java/com/rabbitmq/jms/util/WhiteListObjectInputStream.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, Clas
141141
}
142142

143143
@Override
144+
@SuppressWarnings("deprecation")
144145
protected Class<?> resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException {
145146
ClassLoader cl = Thread.currentThread().getContextClassLoader();
146147
Class[] ifaces = new Class[interfaces.length];

0 commit comments

Comments
 (0)