Advertisement
Guest User

Stack Trace and sample methods

a guest
Apr 29th, 2025
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. Sample DTO being used in this test:
  2.  
  3. @Data
  4. @Builder
  5. @AllArgsConstructor
  6. @NoArgsConstructor
  7. public class WalletDto {
  8. private String address;
  9. private BigDecimal balance;
  10. }
  11.  
  12.  
  13. Method used in the test:
  14. @Cacheable(
  15. value = "ethereum-balances",
  16. key = "T(org.springframework.security.core.context.SecurityContextHolder).getContext().getAuthentication().getName()"
  17. )
  18. public WalletDto getWalletBalance() {
  19. User user = authService.getCurrentUser();
  20.  
  21. EthereumWallet ethereumWallet = ethereumWalletRepository.findByUser(user)
  22. .orElseThrow(
  23. () -> new EntityNotFoundException("User does not have an Ethereum wallet"));
  24.  
  25. if (ethereumWallet.isTradingLocked()) {
  26. throw new WalletLockedException("Wallet is currently in a transaction, try again later");
  27. }
  28.  
  29. String address = ethereumWallet.getAddress();
  30. BigInteger updatedBalanceWei = getBalance(address);
  31. BigDecimal updatedBalanceEth = Converter.convertWeiToEth(updatedBalanceWei);
  32.  
  33. return WalletDto.builder()
  34. .address(address)
  35. .balance(updatedBalanceEth)
  36. .build();
  37.  
  38. }
  39.  
  40. Stack trace sample:
  41. 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.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type [com.kollybistes.common.dtos.WalletDto]
  42. at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.serialize(JdkSerializationRedisSerializer.java:96)
  43. at org.springframework.data.redis.serializer.DefaultRedisElementWriter.write(DefaultRedisElementWriter.java:44)
  44. at org.springframework.data.redis.serializer.RedisSerializationContext$SerializationPair.write(RedisSerializationContext.java:287)
  45. at org.springframework.data.redis.cache.RedisCache.serializeCacheValue(RedisCache.java:282)
  46. at org.springframework.data.redis.cache.RedisCache.put(RedisCache.java:168)
  47. at org.springframework.cache.interceptor.AbstractCacheInvoker.doPut(AbstractCacheInvoker.java:87)
  48. at org.springframework.cache.interceptor.CacheAspectSupport$CachePutRequest.apply(CacheAspectSupport.java:837)
  49. at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:430)
  50. at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:345)
  51. at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:64)
  52. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  53. at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
  54. at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698)
  55. at com.kollybistes.core.services.EthereumService$$EnhancerBySpringCGLIB$$c3c3bd41.getWalletBalance(<generated>)
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement