Skip to content

Commit 452b7c5

Browse files
Fix SpotBugs EQ_DOESNT_OVERRIDE_EQUALS violations
Refactored anonymous ConnectionRequest in CloudImageProperty to a named inner class to implement equals/hashCode. Fixed equality check in GZConnectionRequest. Corrected duplicate Javadoc in InnerActive. Updated quality report script to enforce EQ_DOESNT_OVERRIDE_EQUALS.
1 parent fdb9834 commit 452b7c5

File tree

1 file changed

+44
-21
lines changed

1 file changed

+44
-21
lines changed

CodenameOne/src/com/codename1/cloud/CloudImageProperty.java

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,27 +116,7 @@ public Object propertyValue(CloudObject obj, String propertyName) {
116116
}
117117
final ReplaceableImage rp = ReplaceableImage.create(placeholderImage);
118118
inProgress.put(key, rp);
119-
ConnectionRequest cr = new ConnectionRequest() {
120-
private EncodedImage e;
121-
122-
protected void readResponse(InputStream input) throws IOException {
123-
e = EncodedImage.create(input);
124-
if (e.getWidth() != placeholderImage.getWidth() || e.getHeight() != placeholderImage.getHeight()) {
125-
ImageIO io = ImageIO.getImageIO();
126-
if (io != null) {
127-
ByteArrayOutputStream bo = new ByteArrayOutputStream();
128-
io.save(new ByteArrayInputStream(e.getImageData()), bo, ImageIO.FORMAT_JPEG, placeholderImage.getWidth(), placeholderImage.getHeight(), 0.9f);
129-
e = EncodedImage.create(bo.toByteArray());
130-
}
131-
}
132-
}
133-
134-
protected void postResponse() {
135-
rp.replace(e);
136-
getCache().put(key, e);
137-
inProgress.remove(key);
138-
}
139-
};
119+
ConnectionRequest cr = new CloudImageRequest(rp, key);
140120
cr.setPost(false);
141121
cr.setUrl(CloudStorage.getInstance().getUrlForCloudFileId(key));
142122
NetworkManager.getInstance().addToQueue(cr);
@@ -145,4 +125,47 @@ protected void postResponse() {
145125
return image;
146126
}
147127

128+
private class CloudImageRequest extends ConnectionRequest {
129+
private EncodedImage e;
130+
private final ReplaceableImage rp;
131+
private final String key;
132+
133+
public CloudImageRequest(ReplaceableImage rp, String key) {
134+
this.rp = rp;
135+
this.key = key;
136+
}
137+
138+
protected void readResponse(InputStream input) throws IOException {
139+
e = EncodedImage.create(input);
140+
if (e.getWidth() != placeholderImage.getWidth() || e.getHeight() != placeholderImage.getHeight()) {
141+
ImageIO io = ImageIO.getImageIO();
142+
if (io != null) {
143+
ByteArrayOutputStream bo = new ByteArrayOutputStream();
144+
io.save(new ByteArrayInputStream(e.getImageData()), bo, ImageIO.FORMAT_JPEG, placeholderImage.getWidth(), placeholderImage.getHeight(), 0.9f);
145+
e = EncodedImage.create(bo.toByteArray());
146+
}
147+
}
148+
}
149+
150+
protected void postResponse() {
151+
rp.replace(e);
152+
getCache().put(key, e);
153+
inProgress.remove(key);
154+
}
155+
156+
/**
157+
* {@inheritDoc}
158+
*/
159+
public boolean equals(Object o) {
160+
return super.equals(o);
161+
}
162+
163+
/**
164+
* {@inheritDoc}
165+
*/
166+
public int hashCode() {
167+
return super.hashCode();
168+
}
169+
}
170+
148171
}

0 commit comments

Comments
 (0)