Skip to content

Commit

Permalink
Merge remote-tracking branch 'Juiceman/boxing-and-unboxing' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneBab committed Nov 11, 2024
2 parents a6ba4c4 + 3986ce1 commit e1aaf1a
Show file tree
Hide file tree
Showing 33 changed files with 362 additions and 372 deletions.
15 changes: 6 additions & 9 deletions src/freenet/client/DefaultMIMETypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,24 @@ protected static synchronized void addMIMEType(short number, String type) {
*/
protected static synchronized void addMIMEType(short number, String type, String[] extensions, String outExtension) {
addMIMEType(number, type);
Short t = Short.valueOf(number);
if(extensions != null) {
for(String ext : extensions) {
ext = ext.toLowerCase();
Short s = mimeTypesByExtension.get(ext);
if(s != null) {
// No big deal
Logger.normal(DefaultMIMETypes.class, "Extension "+ext+" assigned to "+byNumber(s.shortValue())+" in preference to "+number+ ':' +type);
Logger.normal(DefaultMIMETypes.class, "Extension "+ext+" assigned to "+byNumber(s)+" in preference to "+number+ ':' +type);
} else {
// If only one, make it primary
if((outExtension == null) && (extensions.length == 1))
primaryExtensionByMimeNumber.put(t, ext);
mimeTypesByExtension.put(ext, t);
primaryExtensionByMimeNumber.put(number, ext);
mimeTypesByExtension.put(ext, number);
}
}
allExtensionsByMimeNumber.put(t, extensions);
allExtensionsByMimeNumber.put(number, extensions);
}
if(outExtension != null)
primaryExtensionByMimeNumber.put(t, outExtension);
primaryExtensionByMimeNumber.put(number, outExtension);

}

Expand Down Expand Up @@ -118,9 +117,7 @@ public synchronized static String byNumber(short x) {
* types, in which case it will have to be sent uncompressed.
*/
public synchronized static short byName(String s) {
Short x = mimeTypesByName.get(s);
if(x != null) return x.shortValue();
else return -1;
return mimeTypesByName.getOrDefault(s, (short) -1);
}

/* From toad's /etc/mime.types
Expand Down
6 changes: 3 additions & 3 deletions src/freenet/client/FailureCodeTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public FailureCodeTracker(boolean isInsert, SimpleFieldSet fs) {
int num = Integer.parseInt(name);
int count = Integer.parseInt(f.get("Count"));
if(count < 0) throw new IllegalArgumentException("Count < 0");
map.put(Integer.valueOf(num), count);
map.put(num, count);
total += count;
}
}
Expand Down Expand Up @@ -192,7 +192,7 @@ public synchronized SimpleFieldSet toFieldSet(boolean verbose) {
for (Map.Entry<Integer, Integer> e : map.entrySet()) {
Integer k = e.getKey();
Integer item = e.getValue();
int code = k.intValue();
int code = k;
// prefix.num.Description=<code description>
// prefix.num.Count=<count>
if(verbose)
Expand All @@ -219,7 +219,7 @@ public InsertExceptionMode getFirstCodeInsert() {
}

public synchronized int getFirstCode() {
return ((Integer) map.keySet().toArray()[0]).intValue();
return (Integer) map.keySet().toArray()[0];
}

public synchronized boolean isFatal(boolean insert) {
Expand Down
16 changes: 8 additions & 8 deletions src/freenet/client/async/USKManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void init(ClientContext context) {
public synchronized long lookupKnownGood(USK usk) {
Long l = latestKnownGoodByClearUSK.get(usk.clearCopy());
if(l != null)
return l.longValue();
return l;
else return -1;
}

Expand All @@ -138,7 +138,7 @@ public synchronized long lookupKnownGood(USK usk) {
public synchronized long lookupLatestSlot(USK usk) {
Long l = latestSlotByClearUSK.get(usk.clearCopy());
if(l != null)
return l.longValue();
return l;
else return -1;
}

Expand Down Expand Up @@ -431,17 +431,17 @@ void updateKnownGood(final USK origUSK, final long number, final ClientContext c
synchronized(this) {
Long l = latestKnownGoodByClearUSK.get(clear);
if(logMINOR) Logger.minor(this, "Old known good: "+l);
if((l == null) || (number > l.longValue())) {
l = Long.valueOf(number);
if((l == null) || (number > l)) {
l = number;
latestKnownGoodByClearUSK.put(clear, l);
if(logMINOR) Logger.minor(this, "Put "+number);
} else
return; // If it's in KnownGood, it will also be in Slot

l = latestSlotByClearUSK.get(clear);
if(logMINOR) Logger.minor(this, "Old slot: "+l);
if((l == null) || (number > l.longValue())) {
l = Long.valueOf(number);
if((l == null) || (number > l)) {
l = number;
latestSlotByClearUSK.put(clear, l);
if(logMINOR) Logger.minor(this, "Put "+number);
newSlot = true;
Expand Down Expand Up @@ -471,8 +471,8 @@ void updateSlot(final USK origUSK, final long number, final ClientContext contex
synchronized(this) {
Long l = latestSlotByClearUSK.get(clear);
if(logMINOR) Logger.minor(this, "Old slot: "+l);
if((l == null) || (number > l.longValue())) {
l = Long.valueOf(number);
if((l == null) || (number > l)) {
l = number;
latestSlotByClearUSK.put(clear, l);
if(logMINOR) Logger.minor(this, "Put "+number);
} else
Expand Down
8 changes: 4 additions & 4 deletions src/freenet/client/filter/FlacFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public void readFilter(
boolean firstHalfOfSyncHeaderFound = false;
ArrayList<Byte> buffer = new ArrayList<Byte>();
int data = 0;
buffer.add(Byte.valueOf((byte) ((frameHeader & 0xFF00) >>> 8)));
buffer.add(Byte.valueOf((byte) (frameHeader & 0x00FF)));
buffer.add((byte) ((frameHeader & 0xFF00) >>> 8));
buffer.add((byte) (frameHeader & 0x00FF));
boolean running = true;
while(running) {
try {
Expand Down Expand Up @@ -90,10 +90,10 @@ public void readFilter(
packet = new FlacFrame(payload);
} else {
firstHalfOfSyncHeaderFound = false;
buffer.add(Byte.valueOf((byte) 0xFF));
buffer.add((byte) 0xFF);
}
}
buffer.add(Byte.valueOf((byte) (data & 0xFF)));
buffer.add((byte) (data & 0xFF));
}
}
if(currentState == State.UNINITIALIZED && packet instanceof FlacMetadataBlock && ((FlacMetadataBlock) packet).isLastMetadataBlock()) {
Expand Down
4 changes: 2 additions & 2 deletions src/freenet/client/filter/OggPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ public OggPage(OggPage oldPage, Collection<CodecPacket> packets) throws IOExcept
int concludingPartialSegment = packet.payload.length % 255;
Logger.minor(this, "Whole segments: "+wholeSegments+" Partial: "+concludingPartialSegment);
for(int i = 0; i < wholeSegments; i++) {
segmentSizes.add(Byte.valueOf(intToUnsignedByte(255)));
segmentSizes.add(intToUnsignedByte(255));
}
if(concludingPartialSegment != 0) {
segmentSizes.add(Byte.valueOf(intToUnsignedByte(concludingPartialSegment)));
segmentSizes.add(intToUnsignedByte(concludingPartialSegment));
}
Logger.minor(this, "Writing packet sized: "+packet.payload.length);
payloadStream.write(packet.payload);
Expand Down
2 changes: 1 addition & 1 deletion src/freenet/clients/http/ConfigToadlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ public void handleMethodGET(URI uri, HTTPRequest req, ToadletContext ctx)
break;
case BOOLEAN:
configItemValueNode.addChild(addBooleanComboBox(
Boolean.valueOf(value), fullName,
Boolean.parseBoolean(value), fullName,
callback.isReadOnly()));
break;
case DIRECTORY:
Expand Down
8 changes: 4 additions & 4 deletions src/freenet/clients/http/ConnectionsToadlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ public void handleMethodGET(URI uri, final HTTPRequest request, ToadletContext c
//i now points to the proper location (equal, insertion point, or end-of-list)
//maybe better called "reverseGroup"?
List<PeerNodeStatus> peerGroup;
if (i<max && locations.get(i).doubleValue()==location) {
if (i<max && locations.get(i) ==location) {
peerGroup=peerGroups.get(i);
} else {
peerGroup=new ArrayList<PeerNodeStatus>();
Expand Down Expand Up @@ -737,7 +737,7 @@ public void handleMethodPOST(URI uri, final HTTPRequest request, ToadletContext
PeerAdditionReturnCodes result=addNewNode(nodesToAdd[i].trim().concat("\nEnd"), privateComment, trust, visibility);
//Store the result
Integer prev = results.get(result);
if(prev == null) prev = Integer.valueOf(0);
if(prev == null) prev = 0;
results.put(result, prev+1);
}

Expand Down Expand Up @@ -1154,7 +1154,7 @@ private void drawMessageTypes(HTMLNode peerTable, PeerNodeStatus peerNodeStatus)
String messageName = entry.getKey();
Long messageCount = entry.getValue();
messageNames.add(messageName);
messageCounts.put(messageName, new Long[] { messageCount, Long.valueOf(0) });
messageCounts.put(messageName, new Long[] { messageCount, 0L});
}
for (Map.Entry<String,Long> entry : peerNodeStatus.getLocalMessagesSent().entrySet() ) {
String messageName = entry.getKey();
Expand All @@ -1164,7 +1164,7 @@ private void drawMessageTypes(HTMLNode peerTable, PeerNodeStatus peerNodeStatus)
}
Long[] existingCounts = messageCounts.get(messageName);
if (existingCounts == null) {
messageCounts.put(messageName, new Long[] { Long.valueOf(0), messageCount });
messageCounts.put(messageName, new Long[] {0L, messageCount });
} else {
existingCounts[1] = messageCount;
}
Expand Down
2 changes: 1 addition & 1 deletion src/freenet/clients/http/HTTPRequestImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ public String[] getParts() {
@Override
public boolean isIncognito() {
if(isParameterSet("incognito"))
return Boolean.valueOf(getParam("incognito"));
return Boolean.parseBoolean(getParam("incognito"));
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/freenet/clients/http/LocalFileInsertToadlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected Hashtable<String, String> persistenceFields (Hashtable<String, String>
}

String element = set.get("compress");
if (element != null && Boolean.valueOf(element)) {
if (element != null && Boolean.parseBoolean(element)) {
fieldPairs.put("compress", element);
}

Expand Down
6 changes: 3 additions & 3 deletions src/freenet/clients/http/StatisticsToadlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -1397,15 +1397,15 @@ private void addNodeCircle (HTMLNode circleTable, double myLocation) {
for(int i=0; i<locations.length; i++){
location = locations[i];
locationTime = timestamps[i];
age = now - locationTime.longValue();
age = now - locationTime;
if( age > MAX_CIRCLE_AGE_THRESHOLD ) {
age = MAX_CIRCLE_AGE_THRESHOLD;
}
strength = 1 - ((double) age / MAX_CIRCLE_AGE_THRESHOLD );
histogramIndex = (int) (Math.floor(location.doubleValue() * HISTOGRAM_LENGTH));
histogramIndex = (int) (Math.floor(location * HISTOGRAM_LENGTH));
histogram[histogramIndex]++;

nodeCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(location.doubleValue(), false, strength), "connected" }, "x");
nodeCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(location, false, strength), "connected" }, "x");
}
nodeCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(myLocation, true, 1.0), "me" }, "x");
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public String postStep(HTTPRequest request) {
// Target for an error page.
StringBuilder target = new StringBuilder(FirstTimeWizardToadlet.WIZARD_STEP.BANDWIDTH_MONTHLY.name()).append("&parseTarget=");
try {
GBPerMonth = Double.valueOf(capTo);
GBPerMonth = Double.parseDouble(capTo);
bytesPerMonth = Math.round(GBPerMonth * DatastoreUtil.oneGiB);
} catch (NumberFormatException e) {
target.append(URLEncoder.encode(capTo, true));
Expand Down
2 changes: 1 addition & 1 deletion src/freenet/crypt/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public static BlockCipher getCipherByName(String name, int keySize) {
return (BlockCipher) Loader.getInstance(
"freenet.crypt.ciphers." + name,
new Class<?>[] { Integer.class },
new Object[] { Integer.valueOf(keySize)});
new Object[] {keySize});
} catch (Exception e) {
//throw new UnsupportedCipherException(""+e);
e.printStackTrace();
Expand Down
2 changes: 1 addition & 1 deletion src/freenet/io/comm/DMT.java
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ public static Message createFNPBestRoutesNotTaken(double[] locs) {

public static Message createFNPBestRoutesNotTaken(Double[] doubles) {
double[] locs = new double[doubles.length];
for(int i=0;i<locs.length;i++) locs[i] = doubles[i].doubleValue();
for(int i=0;i<locs.length;i++) locs[i] = doubles[i];
return createFNPBestRoutesNotTaken(locs);
}

Expand Down
4 changes: 2 additions & 2 deletions src/freenet/io/comm/MessageCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,9 @@ public Map<String, Integer> getUnclaimedFIFOMessageCounts() {
String messageName = m.getSpec().getName();
Integer messageCount = messageCounts.get(messageName);
if (messageCount == null) {
messageCounts.put(messageName, Integer.valueOf(1) );
messageCounts.put(messageName, 1);
} else {
messageCount = Integer.valueOf(messageCount.intValue() + 1);
messageCount = messageCount + 1;
messageCounts.put(messageName, messageCount );
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/freenet/io/comm/MessageType.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public MessageType(String name, short priority, boolean internal, boolean isLoss
this.isLossyPacketMessage = isLossyPacketMessage;
internalOnly = internal;
// XXX hashCode() is NOT required to be unique!
Integer id = Integer.valueOf(name.hashCode());
Integer id = name.hashCode();
if (_specs.containsKey(id)) {
throw new RuntimeException("A message type by the name of " + name + " already exists!");
}
_specs.put(id, this);
}

public void unregister() {
_specs.remove(Integer.valueOf(_name.hashCode()));
_specs.remove(_name.hashCode());
}

public void addLinkedListField(String name, Class<?> parameter) {
Expand Down
6 changes: 3 additions & 3 deletions src/freenet/node/DarknetPeerNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public boolean readExtraPeerData() {
synchronized(extraPeerDataFileNumbers) {
extraPeerDataFileNumbers.add(fileNumber);
}
readResult = readExtraPeerDataFile(extraPeerDataFile, fileNumber.intValue());
readResult = readExtraPeerDataFile(extraPeerDataFile, fileNumber);
if(!readResult) {
gotError = true;
}
Expand Down Expand Up @@ -733,7 +733,7 @@ public void removeExtraPeerDataDir() {
localFileNumbers = extraPeerDataFileNumbers.toArray(new Integer[extraPeerDataFileNumbers.size()]);
}
for (Integer localFileNumber : localFileNumbers) {
deleteExtraPeerDataFile(localFileNumber.intValue());
deleteExtraPeerDataFile(localFileNumber);
}
extraPeerDataPeerDir.delete();
}
Expand Down Expand Up @@ -826,7 +826,7 @@ public void sendQueuedN2NMs() {
}
Arrays.sort(localFileNumbers);
for (Integer localFileNumber : localFileNumbers) {
rereadExtraPeerDataFile(localFileNumber.intValue());
rereadExtraPeerDataFile(localFileNumber);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/freenet/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -4287,7 +4287,7 @@ public synchronized void registerNodeToNodeMessageListener(int type, NodeToNodeM
* Handle a received node to node message
*/
public void receivedNodeToNodeMessage(Message m, PeerNode src) {
int type = ((Integer) m.getObject(DMT.NODE_TO_NODE_MESSAGE_TYPE)).intValue();
int type = (Integer) m.getObject(DMT.NODE_TO_NODE_MESSAGE_TYPE);
ShortBuffer messageData = (ShortBuffer) m.getObject(DMT.NODE_TO_NODE_MESSAGE_DATA);
receivedNodeToNodeMessage(src, type, messageData, false);
}
Expand Down
11 changes: 4 additions & 7 deletions src/freenet/node/NodeDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,7 @@ public void run() {
private boolean handleRoutedRejected(Message m) {
if(!node.enableRoutedPing()) return true;
long id = m.getLong(DMT.UID);
Long lid = Long.valueOf(id);
RoutedContext rc = routedContexts.get(lid);
RoutedContext rc = routedContexts.get(id);
if(rc == null) {
// Gah
Logger.error(this, "Unrecognized FNPRoutedRejected");
Expand Down Expand Up @@ -886,12 +885,11 @@ boolean handleRouted(Message m, PeerNode source) {
if(logMINOR) Logger.minor(this, "handleRouted("+m+ ')');

long id = m.getLong(DMT.UID);
Long lid = Long.valueOf(id);
short htl = m.getShort(DMT.HTL);
byte[] identity = ((ShortBuffer) m.getObject(DMT.NODE_IDENTITY)).getData();
if(source != null) htl = source.decrementHTL(htl);
RoutedContext ctx;
ctx = routedContexts.get(lid);
ctx = routedContexts.get(id);
if(ctx != null) {
try {
source.sendAsync(DMT.createFNPRoutedRejected(id, htl), null, nodeStats.routedMessageCtr);
Expand All @@ -902,7 +900,7 @@ boolean handleRouted(Message m, PeerNode source) {
}
ctx = new RoutedContext(m, source, identity);
synchronized (routedContexts) {
routedContexts.put(lid, ctx);
routedContexts.put(id, ctx);
}
// source == null => originated locally, keep full htl
double target = m.getDouble(DMT.TARGET_LOCATION);
Expand Down Expand Up @@ -930,8 +928,7 @@ boolean handleRoutedReply(Message m) {
if(!node.enableRoutedPing()) return true;
long id = m.getLong(DMT.UID);
if(logMINOR) Logger.minor(this, "Got reply: "+m);
Long lid = Long.valueOf(id);
RoutedContext ctx = routedContexts.get(lid);
RoutedContext ctx = routedContexts.get(id);
if(ctx == null) {
Logger.error(this, "Unrecognized routed reply: "+m);
return false;
Expand Down
Loading

0 comments on commit e1aaf1a

Please sign in to comment.