Jump to content
  • 0

[Help] Error or ?


Bobi

Question

any can help me to fix this problem ?

its happen when event need send announcement with top 3 killers

 

java.lang.NullPointerException
at javolution.util.FastMap.remove(Unknown Source)
at com.l2jarchid.gameserver.event.DM.selectTop(DM.java:118)
at com.l2jarchid.gameserver.event.DM.access$200(DM.java:27)
at com.l2jarchid.gameserver.event.DM$Core.run(DM.java:58)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

since we dont have any code to work with i can only tell you to:

 

at com.l2jarchid.gameserver.event.DM.selectTop(DM.java:118)

before remove to make a check if (whatIWantToRemove != null)

 

btw you are not trying to remove from a map inside a foreach loop, are you? if thats the problem use iterator.remove

Link to comment
Share on other sites

  • 0

and what should do there the system?

 

109 		                for(int i = 0; i < 3; i++) 
110	 		                { 
111	 		                        L2PcInstance max; 
112	 		                        max = temp.head().getNext().getKey(); 
113	 		                        for (L2PcInstance player : temp.keySet()) 
114	 		                                if (temp.get(player)[2] > temp.get(max)[2]) 
115	 		                                        max = player; 
116	 		                         
117	 		                        top[i] = max; 
118	 		                        temp.remove(max); 
119	 		                         
120	 		                } 
121	 		                 
122	 		                 
123	 		        } 
124	 		         

Link to comment
Share on other sites

  • 0

it would appear temp is a Map. It comes to this statement and tries to delete a record from it. However temp has not been initialized so it's equal to null. You need to make sure temp has been created using Map temp = new FastMap<key,value>();

 

Made a quick example:

Map<Integer,String> amap = new HashMap<Integer,String>();
Integer number1 = 1;
Integer number2 = null;
String astring = "Test";
amap.put(number1, astring);
amap.remove(number2);
System.out.println("Done!");

This works ok! number2 (max in your program) can be null and still passed to remove. However, if you don't initalize the Map:

Map<Integer,String> amap = null;
Integer number1 = 1;
Integer number2 = null;
String astring = "Test";
amap.put(number1, astring);
amap.remove(number2);
System.out.println("Done!");

You're gonna get a null pointer exception.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...