{"action":"created","issue":{"url":"https://api.github.com/repos/LightJason/AgentSpeak/issues/44","repository_url":"https://api.github.com/repos/LightJason/AgentSpeak","labels_url":"https://api.github.com/repos/LightJason/AgentSpeak/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/LightJason/AgentSpeak/issues/44/comments","events_url":"https://api.github.com/repos/LightJason/AgentSpeak/issues/44/events","html_url":"https://github.com/LightJason/AgentSpeak/issues/44","id":250364073,"number":44,"title":"Agents store Triggers by hashCode and drop them on hash collision","user":{"login":"SebAlbert","id":2102858,"avatar_url":"https://avatars0.githubusercontent.com/u/2102858?v=4","gravatar_id":"","url":"https://api.github.com/users/SebAlbert","html_url":"https://github.com/SebAlbert","followers_url":"https://api.github.com/users/SebAlbert/followers","following_url":"https://api.github.com/users/SebAlbert/following{/other_user}","gists_url":"https://api.github.com/users/SebAlbert/gists{/gist_id}","starred_url":"https://api.github.com/users/SebAlbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SebAlbert/subscriptions","organizations_url":"https://api.github.com/users/SebAlbert/orgs","repos_url":"https://api.github.com/users/SebAlbert/repos","events_url":"https://api.github.com/users/SebAlbert/events{/privacy}","received_events_url":"https://api.github.com/users/SebAlbert/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-08-15T16:18:44Z","updated_at":"2017-08-15T20:06:10Z","closed_at":null,"body":"When a trigger is added to an agent (and saved for execution in the next cycle), this is done in a Map with the trigger's hashCode as key. If there already is a trigger with the same hashCode, the second (and third, ...) trigger will not be saved and executed, but rather silently dropped. It seems reasonable to suppress duplicate triggers, but hashCode is not generally safe from collisions; two actually different trigger objects might return the same hashCode.\r\n\r\nhttps://github.com/LightJason/AgentSpeak/blob/93971f0356be3f42ef467437b51fec1e3e3a1265/src/main/java/org/lightjason/agentspeak/agent/IBaseAgent.java#L353\r\n\r\nAlthough actual occurrences of this being a problem will probably be rare, wouldn't it make more sense to use a HashSet or similar instead of a Map, or was this design chosen on purpose?"},"comment":{"url":"https://api.github.com/repos/LightJason/AgentSpeak/issues/comments/322573803","html_url":"https://github.com/LightJason/AgentSpeak/issues/44#issuecomment-322573803","issue_url":"https://api.github.com/repos/LightJason/AgentSpeak/issues/44","id":322573803,"user":{"login":"SebAlbert","id":2102858,"avatar_url":"https://avatars0.githubusercontent.com/u/2102858?v=4","gravatar_id":"","url":"https://api.github.com/users/SebAlbert","html_url":"https://github.com/SebAlbert","followers_url":"https://api.github.com/users/SebAlbert/followers","following_url":"https://api.github.com/users/SebAlbert/following{/other_user}","gists_url":"https://api.github.com/users/SebAlbert/gists{/gist_id}","starred_url":"https://api.github.com/users/SebAlbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SebAlbert/subscriptions","organizations_url":"https://api.github.com/users/SebAlbert/orgs","repos_url":"https://api.github.com/users/SebAlbert/repos","events_url":"https://api.github.com/users/SebAlbert/events{/privacy}","received_events_url":"https://api.github.com/users/SebAlbert/received_events","type":"User","site_admin":false},"created_at":"2017-08-15T20:06:10Z","updated_at":"2017-08-15T20:06:10Z","body":"```\r\ndiff --git a/src/test/java/org/lightjason/agentspeak/agent/TestCAgentExecution.java b/src/test/java/org/lightjason/agentspeak/agent/TestCAgentExecution.java\r\nindex 1d74672a0..366d87e59 100644\r\n--- a/src/test/java/org/lightjason/agentspeak/agent/TestCAgentExecution.java\r\n+++ b/src/test/java/org/lightjason/agentspeak/agent/TestCAgentExecution.java\r\n@@ -120,6 +120,8 @@ public final class TestCAgentExecution extends IBaseTest\r\n         m_result.put( 1L, \"twovalues equal type\" );\r\n         m_result.put( 1L, \"twovalues different type\" );\r\n         m_result.put( 1L, \"twovalues with literal\" );\r\n+        m_result.put( 1L, \"hash collision on trigger Ea with FB\" );\r\n+        m_result.put( 1L, \"hash collision on trigger FB with Ea\" );\r\n         m_result.put( 2L, \"single\" );\r\n     }\r\n \r\ndiff --git a/src/test/resources/agent/execution.asl b/src/test/resources/agent/execution.asl\r\nindex fe46b73d9..ef9d182a6 100644\r\n--- a/src/test/resources/agent/execution.asl\r\n+++ b/src/test/resources/agent/execution.asl\r\n@@ -40,6 +40,9 @@\r\n     !doublecall;\r\n     !doublecall;\r\n \r\n+    !hashcollision/Ea;\r\n+    !hashcollision/FB;\r\n+\r\n     !multiple( \"first\" );\r\n     !multiple( \"second\" );\r\n \r\n@@ -56,6 +59,12 @@\r\n +!doublecall <- log(\"single run\").\r\n \r\n /**\r\n+ * hash collision on trigger, both should run\r\n+ **/\r\n++!hashcollision/Ea <- log(\"hash collision on trigger Ea with FB\").\r\n++!hashcollision/FB <- log(\"hash collision on trigger FB with Ea\").\r\n+\r\n+/**\r\n  * called mutiple times\r\n  */\r\n +!multiple(X) <- log(X); !single.\r\n```"}}
{"actor":{"display_login":"SebAlbert"}}