[ 
https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770130#action_12770130
 ] 

Les Hazlewood commented on SHIRO-96:
------------------------------------

Hi Kalle,

I think you've definitely found the cause of the issues we're seeing with the 
test case, however, I think we're side-stepping the true cause of the problem 
by focusing on the SoftHashMap.

Adding in the call on line 252 per your suggestion would result in a little 
more deterministic behavior (and I certainly don't disagree to putting it in 
there), but it is not 'wrong' IMO to leave that line out:  it is intended that 
the map could indeed throw out GC'd values whenever the runtime feels like it, 
so 'losing' values is perfectly acceptable and so the existing implementation 
works as expected for memory-constrained caching.

Also, the default hard-reference retention size is 100, so it is possible that 
anything beyond that #, even with your addition, could still result in 
cache-miss behavior.

The real cause of the issues, at least I think, is that we're using a Cache to 
back non-transient account data.  In the case of a PropertiesRealm or IniRealm, 
we shouldn't be storing the constructed Account objects in a cache at all 
because a cache by nature won't necessarily guarantee data longevity.  I think 
we need to change those implementations to use a HashMap or ConcurrentHashMap 
so the values are never garbage-collected after construction for these 
'memory-only' type of Realms.

And now that I remembered correctly, Alan opened SHIRO-49 for just this reason 
:)

> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as 
> well). Assert login/logout and remember me functionality. Also updating 
> htmlunit to newly released 2.6. Note that tests revealed an interesting 
> thread-safety issue: sometimes 
> getAuthorizationCache().get(upToken.getUsername()); on line 141 of 
> SimpleAccountRealm returned null, causing the authentication to fail. It 
> happened much frequently when I was running the test via Eclipse, but 
> couldn't get it to run when running via Maven. I took an initial look at the 
> CacheManager and didn't follow through completely, but it looked like that a 
> map initialization somewhere may not have been synchronized. Note that these 
> tests run considerably faster than if a human was using a browser but 
> otherwise they don't semantically do anything else different. A patch to 
> follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to