Implemented hashcode (and equals) to prevent NPE with Spring 2.5
This commit is contained in:
parent
a458d21b9f
commit
acd87918d2
|
@ -16,10 +16,12 @@
|
||||||
package org.springframework.security.util;
|
package org.springframework.security.util;
|
||||||
|
|
||||||
import org.springframework.core.io.AbstractResource;
|
import org.springframework.core.io.AbstractResource;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +48,7 @@ public class InMemoryResource extends AbstractResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public InMemoryResource(byte[] source, String description) {
|
public InMemoryResource(byte[] source, String description) {
|
||||||
|
Assert.notNull(source);
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
@ -59,4 +62,16 @@ public class InMemoryResource extends AbstractResource {
|
||||||
public InputStream getInputStream() throws IOException {
|
public InputStream getInputStream() throws IOException {
|
||||||
return new ByteArrayInputStream(source);
|
return new ByteArrayInputStream(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return source.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object res) {
|
||||||
|
if (res instanceof InMemoryResource) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Arrays.equals(source, ((InMemoryResource)res).source);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue