eishub / eis

The Environment Interface Standard (EIS) is a Java-based interface standard for connecting agents to controllable entities in an environment such as a game. The interface provides support for managing the connection (e.g., for pausing and terminating an environment) and for interaction between agents and entities that are available in an environment (e.g., bots in a game). An agent that is connected to a controllable entity receives percepts from and can send actions to that entity. Percepts inform the agent about the state of the entity and its environment. Actions tell the entity which actions to perform in its environment. Several example implementations of environments are available @github.com/eishub. A default implementation of the EIS interface is also provided.
GNU General Public License v3.0
9 stars 4 forks source link

Nullpointer eis.EIDefaultImpl.notifyIfFree #35

Closed Wouter1 closed 10 years ago

Wouter1 commented 10 years ago

carriage is hanging when you press kill button in GOAL. Other envs show the same problem. I do get some messages on the console

GOAL agent Carriage was killed.
WARNING: Could not free agent from environment
nl.tudelft.goal.messaging.exceptions.MessagingException: Waiting for message reply was interrupted
    at nl.tudelft.goal.messaging.RpcWithMessage.call(RpcWithMessage.java:107)
    at rmimessaging.messagebox.RmiMessageBox.blockingSend(RmiMessageBox.java:130)
    at goal.core.runtime.service.environmentport.EnvironmentPort.callRemoteAction(EnvironmentPort.java:191)
    at goal.core.runtime.service.environmentport.EnvironmentPort.freeAgent(EnvironmentPort.java:346)
    at goal.core.agent.DefaultEnvironmentCapabilities.dispose(DefaultEnvironmentCapabilities.java:98)
    at goal.core.agent.Agent.dispose(Agent.java:105)
    at goal.core.agent.Process$1.run(Process.java:37)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.InterruptedException
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireInterruptibly(AbstractQueuedSynchronizer.java:1219)
    at java.util.concurrent.locks.ReentrantLock.lockInterruptibly(ReentrantLock.java:340)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:439)
    at nl.tudelft.goal.messaging.RpcWithMessage.call(RpcWithMessage.java:104)
    ... 7 more
GOAL agent Carriage_0 was killed.
WARNING: Could not free agent from environment
nl.tudelft.goal.messaging.exceptions.MessagingException: Waiting for message reply was interrupted
    at nl.tudelft.goal.messaging.RpcWithMessage.call(RpcWithMessage.java:107)
    at rmimessaging.messagebox.RmiMessageBox.blockingSend(RmiMessageBox.java:130)
    at goal.core.runtime.service.environmentport.EnvironmentPort.callRemoteAction(EnvironmentPort.java:191)
    at goal.core.runtime.service.environmentport.EnvironmentPort.freeAgent(EnvironmentPort.java:346)
    at goal.core.agent.DefaultEnvironmentCapabilities.dispose(DefaultEnvironmentCapabilities.java:98)
    at goal.core.agent.Agent.dispose(Agent.java:105)
    at goal.core.agent.Process$1.run(Process.java:37)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.InterruptedException
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireInterruptibly(AbstractQueuedSynchronizer.java:1219)
    at java.util.concurrent.locks.ReentrantLock.lockInterruptibly(ReentrantLock.java:340)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:439)
    at nl.tudelft.goal.messaging.RpcWithMessage.call(RpcWithMessage.java:104)
    ... 7 more
WARNING: Environment returned an error
java.lang.NullPointerException
    at eis.EIDefaultImpl.notifyIfFree(EIDefaultImpl.java:351)
    at eis.EIDefaultImpl.freeAgent(EIDefaultImpl.java:558)
    at goal.core.runtime.service.environment.LocalMessagingEnvironment$Messages2Environment.invoke(LocalMessagingEnvironment.java:215)
    at goal.core.runtime.service.environmentport.actions.FreeAgent.invoke(FreeAgent.java:30)
    at goal.core.runtime.service.environment.LocalMessagingEnvironment$Messages2Environment.handleAction(LocalMessagingEnvironment.java:169)
    at goal.core.runtime.service.environment.LocalMessagingEnvironment$Messages2Environment.run(LocalMessagingEnvironment.java:153)
    at java.lang.Thread.run(Thread.java:745)
WARNING: Environment returned an error
java.lang.NullPointerException
    at eis.EIDefaultImpl.notifyIfFree(EIDefaultImpl.java:351)
    at eis.EIDefaultImpl.freeAgent(EIDefaultImpl.java:558)
    at goal.core.runtime.service.environment.LocalMessagingEnvironment$Messages2Environment.invoke(LocalMessagingEnvironment.java:215)
    at goal.core.runtime.service.environmentport.actions.FreeAgent.invoke(FreeAgent.java:30)
    at goal.core.runtime.service.environment.LocalMessagingEnvironment$Messages2Environment.handleAction(LocalMessagingEnvironment.java:169)
    at goal.core.runtime.service.environment.LocalMessagingEnvironment$Messages2Environment.run(LocalMessagingEnvironment.java:153)
    at java.lang.Thread.run(Thread.java:745)
Wouter1 commented 10 years ago

at kill time, somewhere in the system we fetch the agents in the environment. We iterate over this list and ask the environment to free each of these agents. We call eis.freeAgent(freeAgent.getAgentName()); (LocalMessagingEnvironment:215)

This call looks all fine, agent has a good name "Carriage".

But apparently the entity already has been removed, agentToEntities is empty and we end up with the call

notifyIfFree(null, [Carriage])

It is a bit inconsistent but I assume that if agentsToEntities does not contain an entry for agent, the agent has no entitites and we can return right away.

koenhindriks commented 10 years ago

Looks like an issue in the default implementation indeed, but it appears more logical to me to return the empty set.

Wouter1 commented 10 years ago

The null came from a hashSet. I did not change that, there are more dependencies on that set and changing its contents may have side effects. If you want to change it that way we must allocate more time to do this.

Wouter1 commented 10 years ago

fixed

Wouter1 commented 10 years ago

fixed

Wouter1 commented 10 years ago

For clarity, that call notifyIfFree and the juggling with that null set is already internally in EIS