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.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;
}

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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;

Datei anzeigen

@ -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());
}

Datei anzeigen

@ -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;

Datei anzeigen

@ -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))

Datei anzeigen

@ -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

Datei anzeigen

@ -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));

Datei anzeigen

@ -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;