I don't now Java can not understand where the mistake was. Using Java 7.
public void chatMessage(String userName, String message) {
IScope scope = Red5.getConnectionLocal().getScope();
ISharedObject chat = getSharedObject(scope, "chat");
List<ChatHistoryItem> history = (List<ChatHistoryItem>) chat.getAttribute("remoteHistory");
ChatHistoryItem item = new ChatHistoryItem();
item.user = userName;
item.date = new Date();
item.message = message;
history.add(item);
chat.setAttribute("remoteHistory", history);
}
error : Unchecked cast from Object to List<ChatHistoryItem>
The issue is because you cannot safely determine the type that will be returned by the ISharedObject.getAttribute
method call. Which occurs in this line:
List<ChatHistoryItem> history = (List<ChatHistoryItem>) chat.getAttribute("remoteHistory");
If the object
returned by this method is not of type List<ChatHistoryItem>
you will receive a ClassCastException
. If the method does return the appropriate type your code will still execute.
I am assuming this is not an error breaking your code, its just a warning from the IDE your using?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.