Fixed a range of smaller bugs discovered by FindBugs.
Dieser Commit ist enthalten in:
Ursprung
a849c38ce6
Commit
53fe3e5b61
@ -32,7 +32,6 @@ import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.injector.PrioritizedListener;
|
||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||
import com.comphenix.protocol.reflect.FuzzyReflection;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.primitives.Longs;
|
||||
|
||||
/**
|
||||
@ -454,11 +453,9 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
|
||||
// Standard equals
|
||||
if (other == this)
|
||||
return true;
|
||||
if (other == null)
|
||||
return false;
|
||||
if (other instanceof AsyncMarker)
|
||||
return Objects.equal(getNewSendingIndex(), ((AsyncMarker) other).getNewSendingIndex());
|
||||
|
||||
return getNewSendingIndex() == ((AsyncMarker) other).getNewSendingIndex();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ package com.comphenix.protocol.async;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.google.common.primitives.Longs;
|
||||
|
||||
/**
|
||||
* Provides a comparable to a packet event.
|
||||
@ -56,4 +57,20 @@ class PacketEventHolder implements Comparable<PacketEventHolder> {
|
||||
compare(sendingIndex, other.sendingIndex).
|
||||
result();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
// Standard equals
|
||||
if (other == this)
|
||||
return true;
|
||||
if (other instanceof PacketEventHolder)
|
||||
return sendingIndex == ((PacketEventHolder) other).sendingIndex;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Longs.hashCode(sendingIndex);
|
||||
}
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ class InjectedArrayList extends ArrayList<Packet> {
|
||||
*/
|
||||
private static final long serialVersionUID = -1173865905404280990L;
|
||||
|
||||
private PlayerInjector injector;
|
||||
private Set<Packet> ignoredPackets;
|
||||
private ClassLoader classLoader;
|
||||
private transient PlayerInjector injector;
|
||||
private transient Set<Packet> ignoredPackets;
|
||||
private transient ClassLoader classLoader;
|
||||
|
||||
public InjectedArrayList(ClassLoader classLoader, PlayerInjector injector, Set<Packet> ignoredPackets) {
|
||||
this.classLoader = classLoader;
|
||||
|
@ -400,7 +400,7 @@ public class StructureModifier<TField> {
|
||||
if (a == null)
|
||||
return b == null;
|
||||
else if (b == null)
|
||||
return a == null;
|
||||
return false;
|
||||
else
|
||||
return a.getSpecificType().equals(b.getSpecificType());
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public final class StructureCompiler {
|
||||
|
||||
// Used to store generated classes of different types
|
||||
@SuppressWarnings("rawtypes")
|
||||
private class StructureKey {
|
||||
private static class StructureKey {
|
||||
private Class targetType;
|
||||
private Class fieldType;
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class CollectionGenerator implements InstanceProvider {
|
||||
@Override
|
||||
public Object create(@Nullable Class<?> type) {
|
||||
// Standard collection types
|
||||
if (type.isInterface()) {
|
||||
if (type != null && type.isInterface()) {
|
||||
if (type.equals(Collection.class) || type.equals(List.class))
|
||||
return new ArrayList<Object>();
|
||||
else if (type.equals(Set.class))
|
||||
|
@ -119,7 +119,6 @@ public class ExistingGenerator implements InstanceProvider {
|
||||
|
||||
@Override
|
||||
public Object create(@Nullable Class<?> type) {
|
||||
|
||||
Object value = existingValues.get(type.getName());
|
||||
|
||||
// NULL values indicate that the generator failed
|
||||
|
@ -57,8 +57,9 @@ public class PrimitiveGenerator implements InstanceProvider {
|
||||
|
||||
@Override
|
||||
public Object create(@Nullable Class<?> type) {
|
||||
|
||||
if (type.isPrimitive()) {
|
||||
if (type == null) {
|
||||
return null;
|
||||
} else if (type.isPrimitive()) {
|
||||
return Defaults.defaultValue(type);
|
||||
} else if (Primitives.isWrapperType(type)) {
|
||||
return Defaults.defaultValue(Primitives.unwrap(type));
|
||||
|
@ -58,7 +58,7 @@ public class SortedCopyOnWriteArrayTest {
|
||||
assertEquals(3, test.get(1).id);
|
||||
}
|
||||
|
||||
private class PriorityStuff implements Comparable<PriorityStuff> {
|
||||
private static class PriorityStuff implements Comparable<PriorityStuff> {
|
||||
public ListenerPriority priority;
|
||||
public int id;
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren