Archiviert
13
0

Fixed a range of smaller bugs discovered by FindBugs.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2012-11-20 07:10:46 +01:00
Ursprung a849c38ce6
Commit 53fe3e5b61
9 geänderte Dateien mit 30 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -32,7 +32,6 @@ import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.injector.PrioritizedListener; import com.comphenix.protocol.injector.PrioritizedListener;
import com.comphenix.protocol.reflect.FieldAccessException; import com.comphenix.protocol.reflect.FieldAccessException;
import com.comphenix.protocol.reflect.FuzzyReflection; import com.comphenix.protocol.reflect.FuzzyReflection;
import com.google.common.base.Objects;
import com.google.common.primitives.Longs; import com.google.common.primitives.Longs;
/** /**
@ -454,11 +453,9 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
// Standard equals // Standard equals
if (other == this) if (other == this)
return true; return true;
if (other == null)
return false;
if (other instanceof AsyncMarker) if (other instanceof AsyncMarker)
return Objects.equal(getNewSendingIndex(), ((AsyncMarker) other).getNewSendingIndex()); return getNewSendingIndex() == ((AsyncMarker) other).getNewSendingIndex();
else
return false; return false;
} }

Datei anzeigen

@ -20,6 +20,7 @@ package com.comphenix.protocol.async;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.ComparisonChain; import com.google.common.collect.ComparisonChain;
import com.google.common.primitives.Longs;
/** /**
* Provides a comparable to a packet event. * Provides a comparable to a packet event.
@ -56,4 +57,20 @@ class PacketEventHolder implements Comparable<PacketEventHolder> {
compare(sendingIndex, other.sendingIndex). compare(sendingIndex, other.sendingIndex).
result(); 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);
}
} }

Datei anzeigen

@ -42,9 +42,9 @@ class InjectedArrayList extends ArrayList<Packet> {
*/ */
private static final long serialVersionUID = -1173865905404280990L; private static final long serialVersionUID = -1173865905404280990L;
private PlayerInjector injector; private transient PlayerInjector injector;
private Set<Packet> ignoredPackets; private transient Set<Packet> ignoredPackets;
private ClassLoader classLoader; private transient ClassLoader classLoader;
public InjectedArrayList(ClassLoader classLoader, PlayerInjector injector, Set<Packet> ignoredPackets) { public InjectedArrayList(ClassLoader classLoader, PlayerInjector injector, Set<Packet> ignoredPackets) {
this.classLoader = classLoader; this.classLoader = classLoader;

Datei anzeigen

@ -400,7 +400,7 @@ public class StructureModifier<TField> {
if (a == null) if (a == null)
return b == null; return b == null;
else if (b == null) else if (b == null)
return a == null; return false;
else else
return a.getSpecificType().equals(b.getSpecificType()); return a.getSpecificType().equals(b.getSpecificType());
} }

Datei anzeigen

@ -94,7 +94,7 @@ public final class StructureCompiler {
// Used to store generated classes of different types // Used to store generated classes of different types
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
private class StructureKey { private static class StructureKey {
private Class targetType; private Class targetType;
private Class fieldType; private Class fieldType;

Datei anzeigen

@ -47,7 +47,7 @@ public class CollectionGenerator implements InstanceProvider {
@Override @Override
public Object create(@Nullable Class<?> type) { public Object create(@Nullable Class<?> type) {
// Standard collection types // Standard collection types
if (type.isInterface()) { if (type != null && type.isInterface()) {
if (type.equals(Collection.class) || type.equals(List.class)) if (type.equals(Collection.class) || type.equals(List.class))
return new ArrayList<Object>(); return new ArrayList<Object>();
else if (type.equals(Set.class)) else if (type.equals(Set.class))

Datei anzeigen

@ -119,7 +119,6 @@ public class ExistingGenerator implements InstanceProvider {
@Override @Override
public Object create(@Nullable Class<?> type) { public Object create(@Nullable Class<?> type) {
Object value = existingValues.get(type.getName()); Object value = existingValues.get(type.getName());
// NULL values indicate that the generator failed // NULL values indicate that the generator failed

Datei anzeigen

@ -57,8 +57,9 @@ public class PrimitiveGenerator implements InstanceProvider {
@Override @Override
public Object create(@Nullable Class<?> type) { public Object create(@Nullable Class<?> type) {
if (type == null) {
if (type.isPrimitive()) { return null;
} else if (type.isPrimitive()) {
return Defaults.defaultValue(type); return Defaults.defaultValue(type);
} else if (Primitives.isWrapperType(type)) { } else if (Primitives.isWrapperType(type)) {
return Defaults.defaultValue(Primitives.unwrap(type)); return Defaults.defaultValue(Primitives.unwrap(type));

Datei anzeigen

@ -58,7 +58,7 @@ public class SortedCopyOnWriteArrayTest {
assertEquals(3, test.get(1).id); assertEquals(3, test.get(1).id);
} }
private class PriorityStuff implements Comparable<PriorityStuff> { private static class PriorityStuff implements Comparable<PriorityStuff> {
public ListenerPriority priority; public ListenerPriority priority;
public int id; public int id;