Ver código fonte

启动空指针异常

779513719 4 anos atrás
pai
commit
51dfc58c23
1 arquivos alterados com 15 adições e 13 exclusões
  1. 15 13
      server-chat/src/main/java/com/cn/ServerChatStart.java

+ 15 - 13
server-chat/src/main/java/com/cn/ServerChatStart.java

@@ -148,19 +148,21 @@ public class ServerChatStart {
                                 GroupConversationMiddle groupConversation = GroupConversationMiddle.dao.findFirst(sql.toString());
                                 if( null != groupConversation ){
                                     Conversation conversation = Conversation.dao.findById(groupConversation.getLong("conversation_id"));
-                                    Timestamp endTime = conversation.getTimestamp("end_time");
-                                    Integer conversationLenth = conversation.getInt("conversation_lenth");
-                                    if( null == endTime && null == conversationLenth ){
-                                        //需要更改会话结束时间 和 对话时长
-                                        long currentTimeMillis = System.currentTimeMillis();
-                                        //当前时间的格林威治时间 毫秒数
-                                        Timestamp currentTime = new Timestamp(currentTimeMillis);
-                                        Timestamp createTime = conversation.getTimestamp("create_time");
-                                        //会话创建时间的格林威治时间 毫秒数
-                                        long createTimeMillis = createTime.getTime();
-                                        if(currentTimeMillis > createTimeMillis){
-                                            conversation.set("end_time",currentTime);
-                                            conversation.set("conversation_lenth",Integer.valueOf( String.valueOf( (currentTimeMillis - createTimeMillis)/1000 )));
+                                    if(conversation != null){
+                                        Timestamp endTime = conversation.getTimestamp("end_time");
+                                        Integer conversationLenth = conversation.getInt("conversation_lenth");
+                                        if( null == endTime && null == conversationLenth ){
+                                            //需要更改会话结束时间 和 对话时长
+                                            long currentTimeMillis = System.currentTimeMillis();
+                                            //当前时间的格林威治时间 毫秒数
+                                            Timestamp currentTime = new Timestamp(currentTimeMillis);
+                                            Timestamp createTime = conversation.getTimestamp("create_time");
+                                            //会话创建时间的格林威治时间 毫秒数
+                                            long createTimeMillis = createTime.getTime();
+                                            if(currentTimeMillis > createTimeMillis){
+                                                conversation.set("end_time",currentTime);
+                                                conversation.set("conversation_lenth",Integer.valueOf( String.valueOf( (currentTimeMillis - createTimeMillis)/1000 )));
+                                            }
                                         }
                                     }
                                 }