This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 583d83f19a Fix type related warnings
583d83f19a is described below
commit 583d83f19a9f7bedf11932eab2058e20d883ae76
Author: remm <[email protected]>
AuthorDate: Thu Mar 20 11:09:14 2025 +0100
Fix type related warnings
---
.../tribes/tipis/AbstractReplicatedMap.java | 37 ++++++++++++----------
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
b/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
index fd74822137..3717a1b6e6 100644
--- a/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
+++ b/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
@@ -225,10 +225,12 @@ public abstract class AbstractReplicatedMap<K, V>
// create a rpc channel and add the map as a listener
this.rpcChannel = new RpcChannel(this.mapContextName, channel, this);
- // add this map as a message listener
- this.channel.addChannelListener(this);
- // listen for membership notifications
- this.channel.addMembershipListener(this);
+ if (this.channel != null) {
+ // add this map as a message listener
+ this.channel.addChannelListener(this);
+ // listen for membership notifications
+ this.channel.addMembershipListener(this);
+ }
try {
// broadcast our map, this just notifies other members of our
existence
@@ -568,7 +570,8 @@ public abstract class AbstractReplicatedMap<K, V>
// backup request
if (mapmsg.getMsgType() == MapMessage.MSG_RETRIEVE_BACKUP) {
- MapEntry<K,V> entry = innerMap.get(mapmsg.getKey());
+ @SuppressWarnings("unchecked")
+ MapEntry<K,V> entry = innerMap.get((K) mapmsg.getKey());
if (entry == null || (!entry.isSerializable())) {
return null;
}
@@ -672,7 +675,7 @@ public abstract class AbstractReplicatedMap<K, V>
}
if (mapmsg.getMsgType() == MapMessage.MSG_PROXY) {
- MapEntry<K,V> entry = innerMap.get(mapmsg.getKey());
+ MapEntry<K,V> entry = innerMap.get((K) mapmsg.getKey());
if (entry == null) {
entry = new MapEntry<>((K) mapmsg.getKey(), (V)
mapmsg.getValue());
MapEntry<K,V> old = innerMap.putIfAbsent(entry.getKey(),
entry);
@@ -688,11 +691,11 @@ public abstract class AbstractReplicatedMap<K, V>
}
if (mapmsg.getMsgType() == MapMessage.MSG_REMOVE) {
- innerMap.remove(mapmsg.getKey());
+ innerMap.remove((K) mapmsg.getKey());
}
if (mapmsg.getMsgType() == MapMessage.MSG_BACKUP ||
mapmsg.getMsgType() == MapMessage.MSG_COPY) {
- MapEntry<K,V> entry = innerMap.get(mapmsg.getKey());
+ MapEntry<K,V> entry = innerMap.get((K) mapmsg.getKey());
if (entry == null) {
entry = new MapEntry<>((K) mapmsg.getKey(), (V)
mapmsg.getValue());
entry.setBackup(mapmsg.getMsgType() == MapMessage.MSG_BACKUP);
@@ -747,7 +750,7 @@ public abstract class AbstractReplicatedMap<K, V>
} // end if
if (mapmsg.getMsgType() == MapMessage.MSG_ACCESS) {
- MapEntry<K,V> entry = innerMap.get(mapmsg.getKey());
+ MapEntry<K,V> entry = innerMap.get((K) mapmsg.getKey());
if (entry != null) {
entry.setBackupNodes(mapmsg.getBackupNodes());
entry.setPrimary(mapmsg.getPrimary());
@@ -758,7 +761,7 @@ public abstract class AbstractReplicatedMap<K, V>
}
if (mapmsg.getMsgType() == MapMessage.MSG_NOTIFY_MAPMEMBER) {
- MapEntry<K,V> entry = innerMap.get(mapmsg.getKey());
+ MapEntry<K,V> entry = innerMap.get((K) mapmsg.getKey());
if (entry != null) {
entry.setBackupNodes(mapmsg.getBackupNodes());
entry.setPrimary(mapmsg.getPrimary());
@@ -997,7 +1000,8 @@ public abstract class AbstractReplicatedMap<K, V>
}
public V remove(Object key, boolean notify) {
- MapEntry<K,V> entry = innerMap.remove(key);
+ @SuppressWarnings("unchecked")
+ MapEntry<K,V> entry = innerMap.remove((K) key);
try {
if (getMapMembers().length > 0 && notify) {
@@ -1011,7 +1015,9 @@ public abstract class AbstractReplicatedMap<K, V>
return entry != null ? entry.getValue() : null;
}
- public MapEntry<K,V> getInternal(Object key) {
+ public MapEntry<K,V> getInternal(Object keyObject) {
+ @SuppressWarnings("unchecked")
+ K key = (K) keyObject;
return innerMap.get(key);
}
@@ -1111,7 +1117,7 @@ public abstract class AbstractReplicatedMap<K, V>
int cnt = 0;
while (i.hasNext()) {
- Map.Entry<?,?> e = i.next();
+ Map.Entry<K,?> e = i.next();
System.out.println((++cnt) + ". " + innerMap.get(e.getKey()));
}
System.out.println("EndMap]\n\n");
@@ -1225,8 +1231,7 @@ public abstract class AbstractReplicatedMap<K, V>
public Set<Map.Entry<K,V>> entrySet() {
LinkedHashSet<Map.Entry<K,V>> set = new
LinkedHashSet<>(innerMap.size());
for (Entry<K,MapEntry<K,V>> e : innerMap.entrySet()) {
- Object key = e.getKey();
- MapEntry<K,V> entry = innerMap.get(key);
+ MapEntry<K,V> entry = innerMap.get(e.getKey());
if (entry != null && entry.isActive()) {
set.add(entry);
}
@@ -1256,7 +1261,7 @@ public abstract class AbstractReplicatedMap<K, V>
// todo, implement a counter variable instead
// only count active members in this node
int counter = 0;
- for (Entry<?, ?> e : innerMap.entrySet()) {
+ for (Entry<K,MapEntry<K,V>> e : innerMap.entrySet()) {
if (e != null) {
MapEntry<K, V> entry = innerMap.get(e.getKey());
if (entry != null && entry.isActive() && entry.getValue() !=
null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]