Hi Sven,

I was thinking about this as well.

SoftReferences worked well in my application. G1GC seems to start to evict
them when -XX:InitiatingHeapOccupancyPercent is reached. In my case, when
the heap is around 60% full.
But as you said, there is no real control over which references are evicted
and it is much harder to monitor the current state of the memory map.

We are already using Caffeine extensively and your suggested solution would
allow me much more control over the cache.
We could still use SoftReferences with Caffeine if we wanted to in addition
to setting a global limit on cache size and an eviction policy.

To avoid calling an overridable method from the constructor you could add a
Supplier<Map<String, MemoryData>> argument. I usually choose a
supplier-based approach in such cases.

Let's go for this solution!

Best regards,

Thomas



On Sun, Apr 12, 2020 at 6:57 PM Sven Meier <s...@meiers.net> wrote:

> Hi Thomas,
>
> I've did a little research on using SoftReferences for caches:
>
> https://stackoverflow.com/questions/264582/is-there-a-softhashmap-in-java
>
> http://jeremymanson.blogspot.com/2009/07/how-hotspot-decides-to-clear_07.html
>
> The experts seem to agree that depending on the GC to clean up your
> cache is a bad idea:
>
> - you can't control which elements in the cache are evicted first
> - eviction happens only when the system is low on memory
>
> Best option would be using Guava's CacheBuilder:
>
>    https://github.com/google/guava/wiki/CachesExplained
>
> IMHO these are very special solutions and we don't actually need to
> integrate one of them into Wicket.
> Instead we can leave that decision to your application, by adding an
> overridable method to InMemoryPageStore:
>
>      /**
>       * Create a map to hold memory data for all sessions.
>       *
>       * @return a {@link ConcurrentHashMap} by default
>       */
>      protected Map<String, MemoryData> newMemoryMap()
>      {
>          return new ConcurrentHashMap<>();
>      }
>
> (Yes, it would be called from the constructor which is a bad practice by
> itself, but this is the simplest solution.)
>
> What do you think?
>
> Sven
>
>
> On 12.04.20 10:34, Thomas Heigl wrote:
> > Hi Sven,
> >
> > That's good to hear! Please let me know when you have an implementation
> and
> > I'll give it another go.
> >
> > Best regards,
> >
> > Thomas
> >
> > On Sat, Apr 11, 2020 at 11:01 PM Sven Meier <s...@meiers.net> wrote:
> >
> >> Hi Thomas,
> >>
> >> actually not bad news at all (for Wicket 9 at least).
> >>
> >> The old page manager implementation had so many special concepts and
> >> solutions, it's easy to miss one.
> >>
> >> A soft reference feature can easily be added/restored. I'm already
> >> checking where it fits best.
> >>
> >> Thanks for your thorough testing.
> >>
> >> Best regards
> >> Sven
> >>
> >>
> >> On 11.04.20 10:58, Thomas Heigl wrote:
> >>> Hi all,
> >>>
> >>> Bad news. My application was caught in a GC loop after running for 8
> >> hours.
> >>> The old generation was exhausted.
> >>>
> >>> I couldn't get a heap dump at that time but restarted the application,
> >> took
> >>> a heap dump after about an hour, and reverted back to Wicket 8.
> >>>
> >>> The problem is this: The heap was full of objects referencing
> >>> InMemoryPageStore, i.e. the in-memory 2nd-level cache for pages. My
> first
> >>> thought was that there is something wrong with the implementation of
> that
> >>> store and pages do not get limited or removed correctly.  So I debugged
> >>> it locally but everything is working fine.
> >>>
> >>> Then I noticed that there are a lot of instances of Hibernate entities
> on
> >>> the heap. So there definitely is an issue with models somewhere in my
> >>> application. To be sure that this is not a new issue, I took another
> heap
> >>> dump from production - now running Wicket 8 again - and compared it.
> >>> There are undetached entity models on the heap as well.
> >>>
> >>> So why does it not OOM with Wicket 8? Well, the PerSessionPageStore
> >>> (roughly the equivalent of InMemoryPageStore in Wicket 9) uses
> >>> SoftReferences for storing pages. InMemoryPageStore does not and GC
> >> cannot
> >>> reclaim memory from it.
> >>>
> >>> So while this surfaced some issues in my application that I just
> fixed, I
> >>> believe that InMemoryPageStore should use SoftReferences or another
> >>> implementation based on SoftReferences should be added to Wicket 9. A
> >> cache
> >>> should not consume all the memory if it can easily re-fetch
> >>> the value from persistent storage.
> >>>
> >>> I guess the reason for not using SoftReferences in InMemoryPageStore is
> >>> that it can theoretically be used as a "persistent" store for pages. If
> >> that
> >>> behavior is really required, I suggest adding another implementation
> >> using
> >>> SoftReferences.
> >>>
> >>> Best regards,
> >>>
> >>> Thomas
> >>>
> >>> On Fri, Apr 10, 2020 at 7:19 PM Martin Grigorov <mgrigo...@apache.org>
> >>> wrote:
> >>>
> >>>> On Fri, Apr 10, 2020 at 4:01 PM Thomas Heigl <tho...@umschalt.com>
> >> wrote:
> >>>>> FYI: I deployed Wicket 9.0.0-M5 to production an hour ago. 100k
> >> requests
> >>>>> served and no issues so far.
> >>>>>
> >>>> Awesome!
> >>>> Thank you for testing it!
> >>>>
> >>>>
> >>>>> Great work!
> >>>>>
> >>>>> Thomas
> >>>>>
> >>>>> On Wed, Apr 8, 2020 at 3:13 PM Sven Meier <s...@meiers.net> wrote:
> >>>>>
> >>>>>> Many thanks Maxim!
> >>>>>>
> >>>>>> Sven
> >>>>>>
> >>>>>> On 08.04.20 14:29, Maxim Solodovnik wrote:
> >>>>>>> Released :)
> >>>>>>>
> >>>>>>> On Wed, 8 Apr 2020 at 15:41, Maxim Solodovnik <
> solomax...@gmail.com>
> >>>>>> wrote:
> >>>>>>>> OK
> >>>>>>>>
> >>>>>>>> Will start new release process in couple of hours
> >>>>>>>> Please stop me if you will find any blocker :)
> >>>>>>>>
> >>>>>>>> On Wed, 8 Apr 2020 at 14:36, Thomas Heigl <tho...@umschalt.com>
> >>>>> wrote:
> >>>>>>>>> Hi Maxim,
> >>>>>>>>>
> >>>>>>>>> It works for me now!
> >>>>>>>>>
> >>>>>>>>> Thomas
> >>>>>>>>>
> >>>>>>>>> On Wed, Apr 8, 2020 at 9:17 AM Maxim Solodovnik <
> >>>>> solomax...@gmail.com>
> >>>>>>>>> wrote:
> >>>>>>>>>
> >>>>>>>>>> Thanks a million!
> >>>>>>>>>>
> >>>>>>>>>> On Wed, 8 Apr 2020 at 14:10, Thomas Heigl <tho...@umschalt.com>
> >>>>>> wrote:
> >>>>>>>>>>> Hi Maxim,
> >>>>>>>>>>>
> >>>>>>>>>>> I'm testing against the snapshot now. Will get back to you
> >>>> shortly.
> >>>>>>>>>>> Thomas
> >>>>>>>>>>>
> >>>>>>>>>>> On Wed, Apr 8, 2020 at 2:53 AM Maxim Solodovnik <
> >>>>>> solomax...@gmail.com>
> >>>>>>>>>>> wrote:
> >>>>>>>>>>>
> >>>>>>>>>>>> Hello All,
> >>>>>>>>>>>>
> >>>>>>>>>>>> M5 seems to be broken (deploy has failed more than 10 times
> >>>> during
> >>>>>> my
> >>>>>>>>>>>> build attempts)
> >>>>>>>>>>>> I have to start another release
> >>>>>>>>>>>> Could you please tell when can I start?
> >>>>>>>>>>>>
> >>>>>>>>>>>> On Wed, 8 Apr 2020 at 07:01, Maxim Solodovnik <
> >>>>> solomax...@gmail.com
> >>>>>>>>>>>> wrote:
> >>>>>>>>>>>>> Hello Thomas,
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Please test M6-SNAPSHOT (so I don't have to release M5.2
> :))))
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> On Wed, 8 Apr 2020 at 02:39, Thomas Heigl <
> tho...@umschalt.com
> >>>>>>>>>> wrote:
> >>>>>>>>>>>>>> Hi Maxim,
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> That would be great. I want to do some more extensive
> testing
> >>>>> and
> >>>>>>>>>> then
> >>>>>>>>>>>>>> deploy M5 into production. ;)
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Thomas
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> On Tue, Apr 7, 2020 at 7:50 PM Maxim Solodovnik <
> >>>>>>>>>> solomax...@gmail.com>
> >>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> I can pack another release
> >>>>>>>>>>>>>>> later this week ...
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> On Wed, 8 Apr 2020 at 00:48, Thomas Heigl <
> >>>> tho...@umschalt.com
> >>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>> Thanks Sven!
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> Did your changes make it into the release? Or did they
> just
> >>>>>>>>>> miss
> >>>>>>>>>>>> it?
> >>>>>>>>>>>>>>>> Thomas
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> On Tue, Apr 7, 2020 at 7:43 PM Sven Meier <
> s...@meiers.net>
> >>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>> Hi Thomas,
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> yes, you're right:
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> wicketstuff data stores missed some adjustments to the
> >>>> latest
> >>>>>>>>>>>> updates
> >>>>>>>>>>>>>>> in
> >>>>>>>>>>>>>>>>> wicket-core.
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> And SessionQuotaManagingDataStore$DelegatedPage must be
> >>>>>>>>>>>> serializable of
> >>>>>>>>>>>>>>>>> course.
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> I've pushed changes to wicketstuff master.
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> Thanks
> >>>>>>>>>>>>>>>>> Sven
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> On 07.04.20 14:14, Thomas Heigl wrote:
> >>>>>>>>>>>>>>>>>> And one more thing. There is now a warning logged just
> >>>>>>>>>> before
> >>>>>>>>>>>>>>>>> serialization:
> >>>>>>>>>>>>>>>>>> WARN o.a.w.pageStore.AsynchronousPageStore    :
> Delegated
> >>>>>>>>>> page
> >>>>>>>>>>>> store
> >>>>>>>>>>>>>>>>>>> 'org.apache.wicket.pageStore.SerializingPageStore' can
> >>>>>>>>>> not be
> >>>>>>>>>>>>>>>>> asynchronous
> >>>>>>>>>>>>>>>>>> On Tue, Apr 7, 2020 at 2:09 PM Thomas Heigl <
> >>>>>>>>>>>> tho...@umschalt.com>
> >>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>> The cause is the following MetaData entry in the
> session:
> >>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>> class
> >>
> org.wicketstuff.datastores.common.SessionQuotaManagingDataStore$1=org.wicketstuff.datastores.common.SessionQuotaManagingDataStore$SizeLimitedData@4090594a
> >>>>>>>>>>>>>>>>>>> On Tue, Apr 7, 2020 at 1:59 PM Thomas Heigl <
> >>>>>>>>>>>> tho...@umschalt.com>
> >>>>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>>> Hi Sven,
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>> I just found time to give this a try with Wicket
> >>>>>>>>>> 9.0.0-M5.
> >>>>>>>>>>>> There
> >>>>>>>>>>>>>>> seem
> >>>>>>>>>>>>>>>>> to
> >>>>>>>>>>>>>>>>>>>> be issues with serialization now.
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>> My new config:
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>> protected IPageStore newCachingStore(IPageStore
> >>>>>>>>>> pageStore) {
> >>>>>>>>>>>>>>>>>>>>> return new CachingPageStore(pageStore, new
> >>>>>>>>>>>>>>>>> InMemoryPageStore(getName(),
> >>>>>>>>>>>>>>>>>>>>> MAX_PAGES_CACHED_PER_SESSION));
> >>>>>>>>>>>>>>>>>>>>> }
> >>>>>>>>>>>>>>>>>>>>> protected IPageStore newPersistentStore() {
> >>>>>>>>>>>>>>>>>>>>> final RedissonRedisCache redisCache = new
> >>>>>>>>>>>>>>>>>>>>> RedissonRedisCache(redissonClient);
> >>>>>>>>>>>>>>>>>>>>> final RedisDataStore redisDataStore = new
> >>>>>>>>>>>>>>> RedisDataStore(getName(),
> >>>>>>>>>>>>>>>>>>>>> redisCache, new RedisSettings());
> >>>>>>>>>>>>>>>>>>>>> return new
> >>>> SessionQuotaManagingDataStore(redisDataStore,
> >>>>>>>>>>>>>>>>>>>>> DATA_STORE_MAX_BYTES_PER_SESSION);
> >>>>>>>>>>>>>>>>>>>>> }
> >>>>>>>>>>>>>>>>>>>> This exception is logged after requests:
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>
> >>>> org.springframework.data.redis.serializer.SerializationException:
> >>>>>>>>>>>>>>>>> Cannot
> >>>>>>>>>>>>>>>>>>>>> serialize; nested exception is
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.core.serializer.support.SerializationFailedException:
> >>>>>>>>>>>>>>>>>>>>> Failed to serialize object using DefaultSerializer;
> >>>>>>>>>> nested
> >>>>>>>>>>>>>>> exception
> >>>>>>>>>>>>>>>>> is
> >>>>>>>>>>>>>>>>>>>>> java.io.NotSerializableException:
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.wicketstuff.datastores.common.SessionQuotaManagingDataStore$DelegatedPage
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.serialize(JdkSerializationRedisSerializer.java:96)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.data.redis.core.AbstractOperations.rawHashValue(AbstractOperations.java:185)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.data.redis.core.DefaultHashOperations.putAll(DefaultHashOperations.java:147)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.data.redis.core.DefaultBoundHashOperations.putAll(DefaultBoundHashOperations.java:147)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.session.data.redis.RedisIndexedSessionRepository$RedisSession.saveDelta(RedisIndexedSessionRepository.java:795)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.session.data.redis.RedisIndexedSessionRepository$RedisSession.save(RedisIndexedSessionRepository.java:783)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.session.data.redis.RedisIndexedSessionRepository$RedisSession.access$000(RedisIndexedSessionRepository.java:670)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.session.data.redis.RedisIndexedSessionRepository.save(RedisIndexedSessionRepository.java:398)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.session.data.redis.RedisIndexedSessionRepository.save(RedisIndexedSessionRepository.java:249)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> com.myproject.session.InstrumentedFindByIndexNameSessionRepository.save(InstrumentedFindByIndexNameSessionRepository.java:29)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>>>>>
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> >>>>>>>>>>>>>>>>>>>>> Method)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>> java.base/java.lang.reflect.Method.invoke(Method.java:566)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> io.micrometer.core.aop.TimedAspect.processWithTimer(TimedAspect.java:105)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>> io.micrometer.core.aop.TimedAspect.timedMethod(TimedAspect.java:94)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>> jdk.internal.reflect.GeneratedMethodAccessor146.invoke(Unknown
> >>>>>>>>>>>>>>>>> Source)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>> java.base/java.lang.reflect.Method.invoke(Method.java:566)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
> >>>>>>>>>>>>>>>>>>>>> at com.sun.proxy.$Proxy296.save(Unknown Source)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper.commitSession(SessionRepositoryFilter.java:225)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper.access$100(SessionRepositoryFilter.java:192)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:144)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:82)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:666)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>> org.apache.tomcat.util.net
> >>>>>>>>>>>>>>>>> .NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1594)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>> org.apache.tomcat.util.net
> >>>>>>>>>>>>>>>>> .SocketProcessorBase.run(SocketProcessorBase.java:49)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> >>>>>>>>>>>>>>>>>>>>> at java.base/java.lang.Thread.run(Thread.java:834)
> >>>>>>>>>>>>>>>>>>>>> Caused by:
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.core.serializer.support.SerializationFailedException:
> >>>>>>>>>>>>>>>>>>>>> Failed to serialize object using DefaultSerializer;
> >>>>>>>>>> nested
> >>>>>>>>>>>>>>> exception
> >>>>>>>>>>>>>>>>> is
> >>>>>>>>>>>>>>>>>>>>> java.io.NotSerializableException:
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.wicketstuff.datastores.common.SessionQuotaManagingDataStore$DelegatedPage
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:68)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:35)
> >>>>>>>>>>>>>>>>>>>>> at
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.serialize(JdkSerializationRedisSerializer.java:94)
> >>>>>>>>>>>>>>>>>>>>> ... 52 common frames omitted
> >>>>>>>>>>>>>>>>>>>>> Caused by: java.io.NotSerializableException:
> >>>>>>>>>>>>>>>>>>>>>
> >>
> org.wicketstuff.datastores.common.SessionQuotaManagingDataStore$DelegatedPage
> >>>>>>>>>>>>>>>>>>>> Why does Wicket 9 try to serialize the
> >>>>>>>>>>>>>>> SessionQuotaManagingDataStore in
> >>>>>>>>>>>>>>>>>>>> the session? Is this intended and does DelegatePage
> >>>>>>>>>> simply
> >>>>>>>>>>>> need to
> >>>>>>>>>>>>>>>>>>>> implement Serializable or shouldn't this be serialized
> >>>> at
> >>>>>>>>>>>> all? In
> >>>>>>>>>>>>>>>>> Wicket 8,
> >>>>>>>>>>>>>>>>>>>> the corresponding PageData wasn't serializable either
> so
> >>>>>>>>>> my
> >>>>>>>>>>>> guess
> >>>>>>>>>>>>>>>>> would be
> >>>>>>>>>>>>>>>>>>>> that this behavior is not intended.
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>> I'm using the following config for Wicket 8 and there
> >>>>>>>>>> are no
> >>>>>>>>>>>> such
> >>>>>>>>>>>>>>>>> issues:
> >>>>>>>>>>>>>>>>>>>> protected IPageStore newPageStore(IDataStore
> dataStore)
> >>>> {
> >>>>>>>>>>>>>>>>>>>>> final ISerializer pageSerializer =
> >>>>>>>>>>>>>>>>>>>>> getFrameworkSettings().getSerializer();
> >>>>>>>>>>>>>>>>>>>>> return new PerSessionPageStore(pageSerializer,
> >>>>>>>>>> dataStore,
> >>>>>>>>>>>>>>>>>>>>> MAX_PAGES_CACHED_PER_SESSION);
> >>>>>>>>>>>>>>>>>>>>> }
> >>>>>>>>>>>>>>>>>>>>> protected IDataStore newDataStore() {
> >>>>>>>>>>>>>>>>>>>>> final RedissonRedisCache redisCache = new
> >>>>>>>>>>>>>>>>>>>>> RedissonRedisCache(redissonClient.get());
> >>>>>>>>>>>>>>>>>>>>> final RedisDataStore redisDataStore = new
> >>>>>>>>>>>>>>> RedisDataStore(redisCache,
> >>>>>>>>>>>>>>>>> new
> >>>>>>>>>>>>>>>>>>>>> RedisSettings());
> >>>>>>>>>>>>>>>>>>>>> return new
> >>>> SessionQuotaManagingDataStore(redisDataStore,
> >>>>>>>>>>>>>>>>>>>>> DATA_STORE_MAX_BYTES_PER_SESSION);
> >>>>>>>>>>>>>>>>>>>>> }
> >>>>>>>>>>>>>>>>>>>> Best regards,
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>> Thomas
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>> On Sat, Mar 28, 2020 at 10:23 AM Thomas Heigl <
> >>>>>>>>>>>> tho...@umschalt.com
> >>>>>>>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>> Thanks Sven!
> >>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>> That looks much better. I'll give it a try as soon
> as I
> >>>>>>>>>> can.
> >>>>>>>>>>>>>>>>>>>>> Best regards,
> >>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>> Thomas
> >>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>> On Fri, Mar 27, 2020 at 2:23 PM Sven Meier <
> >>>>>>>>>> s...@meiers.net
> >>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>>>>> Hi Thomas,
> >>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>> your question comes at the right time.
> >>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>> I was able to improve the implementation with a new
> >>>>>>>>>>>>>>> CachingPageStore:
> >>
> https://github.com/apache/wicket/blob/8df3528dc44a08b7d375c20e764a3664cd6a5f30/wicket-core/src/main/java/org/apache/wicket/DefaultPageManagerProvider.java#L145
> >>>>>>>>>>>>>>>>>>>>>> You can now use InMemoryPageStore as a cache too.
> >>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>> Have fun
> >>>>>>>>>>>>>>>>>>>>>> Sven
> >>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>> On 27.03.20 09:34, Sven Meier wrote:
> >>>>>>>>>>>>>>>>>>>>>>> Hi Thomas,
> >>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>> I thought I covered that usecase, but I will have
> to
> >>>>>>>>>> take
> >>>>>>>>>>>> a
> >>>>>>>>>>>>>>> look.
> >>>>>>>>>>>>>>>>>>>>>>> Thanks for testing Wicket 9
> >>>>>>>>>>>>>>>>>>>>>>> Sven
> >>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>> On 25.03.20 20:10, Thomas Heigl wrote:
> >>>>>>>>>>>>>>>>>>>>>>>> Maybe the same approach could be used as for
> >>>>>>>>>>>> InSessionPageStore
> >>>>>>>>>>>>>>>>> that
> >>>>>>>>>>>>>>>>>>>>>>>> can be
> >>>>>>>>>>>>>>>>>>>>>>>> used as cache and a store:
> >>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>
> >>
> https://github.com/apache/wicket/commit/894799e01227781be76886b2d1cdb2a424c812e0
> >>>>>>>>>>>>>>>>>>>>>>>> On Wed, Mar 25, 2020 at 6:35 PM Thomas Heigl <
> >>>>>>>>>>>>>>> tho...@umschalt.com>
> >>>>>>>>>>>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>> Hi all,
> >>>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>> I just merged our master in our Wicket 9 branch
> and
> >>>>>>>>>> I
> >>>>>>>>>>>> ran
> >>>>>>>>>>>>>>> into an
> >>>>>>>>>>>>>>>>>>>>>>>>> issue:
> >>>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>> Our current configuration with Wicket 8 looks
> like
> >>>>>>>>>> this:
> >>>>>>>>>>>>>>>>>>>>>>>>> PageStore = PerSessionPageStore
> >>>>>>>>>>>>>>>>>>>>>>>>> DataStore = RedisDataStore
> >>>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>> So the page store keeps the last couple of pages
> of
> >>>>>>>>>> a
> >>>>>>>>>>>> session
> >>>>>>>>>>>>>>> in
> >>>>>>>>>>>>>>>>>>>>>> memory
> >>>>>>>>>>>>>>>>>>>>>>>>> and Redis is used as a persistent store.
> >>>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>> I tried to recreate this behavior with Wicket 9:
> >>>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>> SessionStore = InMemoryPageStore
> >>>>>>>>>>>>>>>>>>>>>>>>> PersistentStore = RedisDataStore
> >>>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>> This looks correct, but it *does not work*
> because
> >>>>>>>>>>>>>>> InMemoryPage
> >>>>>>>>>>>>>>>>>>>>>> store
> >>>>>>>>>>>>>>>>>>>>>>>>> implements AbstractPersistentPageStore and does
> >>>>>>>>>> *not*
> >>>>>>>>>>>>>>> delegate to
> >>>>>>>>>>>>>>>>>>>>>> the
> >>>>>>>>>>>>>>>>>>>>>>>>> next store in the chain.
> >>>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>> So we basically lost the option to use a memory
> >>>> page
> >>>>>>>>>>>> store in
> >>>>>>>>>>>>>>>>> front
> >>>>>>>>>>>>>>>>>>>>>>>>> of a
> >>>>>>>>>>>>>>>>>>>>>>>>> persistent store.
> >>>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>> We need this functionality because we are using
> >>>>>>>>>> Spring
> >>>>>>>>>>>>>>> Session and
> >>>>>>>>>>>>>>>>>>>>>>>>> cannot
> >>>>>>>>>>>>>>>>>>>>>>>>> use the session as a page store.
> >>>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>> Would it be possible to add an InMemory store
> that
> >>>>>>>>>>>> delegates
> >>>>>>>>>>>>>>> to
> >>>>>>>>>>>>>>>>> the
> >>>>>>>>>>>>>>>>>>>>>>>>> next
> >>>>>>>>>>>>>>>>>>>>>>>>> store in the chain? Or do I have to implement it
> >>>>>>>>>> myself?
> >>>>>>>>>>>>>>>>>>>>>>>>> Best regards,
> >>>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>> Thomas
> >>>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>>>>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
> >>>>>>>>>>>> users-unsubscr...@wicket.apache.org
> >>>>>>>>>>>>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>>>> users-h...@wicket.apache.org
> >>>>> ---------------------------------------------------------------------
> >>>>>>>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
> >>>>>>>>>>>> users-unsubscr...@wicket.apache.org
> >>>>>>>>>>>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>>>> users-h...@wicket.apache.org
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
> >>>> users-unsubscr...@wicket.apache.org
> >>>>>>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>> users-h...@wicket.apache.org
> >>>>>>>>>>>>>>> --
> >>>>>>>>>>>>>>> Best regards,
> >>>>>>>>>>>>>>> Maxim
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>>>>>>>>>>>> To unsubscribe, e-mail:
> users-unsubscr...@wicket.apache.org
> >>>>>>>>>>>>>>> For additional commands, e-mail:
> >>>> users-h...@wicket.apache.org
> >>>>>>>>>>>>> --
> >>>>>>>>>>>>> Best regards,
> >>>>>>>>>>>>> Maxim
> >>>>>>>>>>>> --
> >>>>>>>>>>>> Best regards,
> >>>>>>>>>>>> Maxim
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>>>>>>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >>>>>>>>>>>> For additional commands, e-mail: users-h...@wicket.apache.org
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>> --
> >>>>>>>>>> Best regards,
> >>>>>>>>>> Maxim
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>>>>>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >>>>>>>>>> For additional commands, e-mail: users-h...@wicket.apache.org
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>> --
> >>>>>>>> Best regards,
> >>>>>>>> Maxim
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >>>>>> For additional commands, e-mail: users-h...@wicket.apache.org
> >>>>>>
> >>>>>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >> For additional commands, e-mail: users-h...@wicket.apache.org
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to