Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sample DTO being used in this test:
- @Data
- @Builder
- @AllArgsConstructor
- @NoArgsConstructor
- public class WalletDto {
- private String address;
- private BigDecimal balance;
- }
- Method used in the test:
- @Cacheable(
- value = "ethereum-balances",
- key = "T(org.springframework.security.core.context.SecurityContextHolder).getContext().getAuthentication().getName()"
- )
- public WalletDto getWalletBalance() {
- User user = authService.getCurrentUser();
- EthereumWallet ethereumWallet = ethereumWalletRepository.findByUser(user)
- .orElseThrow(
- () -> new EntityNotFoundException("User does not have an Ethereum wallet"));
- if (ethereumWallet.isTradingLocked()) {
- throw new WalletLockedException("Wallet is currently in a transaction, try again later");
- }
- String address = ethereumWallet.getAddress();
- BigInteger updatedBalanceWei = getBalance(address);
- BigDecimal updatedBalanceEth = Converter.convertWeiToEth(updatedBalanceWei);
- return WalletDto.builder()
- .address(address)
- .balance(updatedBalanceEth)
- .build();
- }
- Stack trace sample:
- 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]
- at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.serialize(JdkSerializationRedisSerializer.java:96)
- at org.springframework.data.redis.serializer.DefaultRedisElementWriter.write(DefaultRedisElementWriter.java:44)
- at org.springframework.data.redis.serializer.RedisSerializationContext$SerializationPair.write(RedisSerializationContext.java:287)
- at org.springframework.data.redis.cache.RedisCache.serializeCacheValue(RedisCache.java:282)
- at org.springframework.data.redis.cache.RedisCache.put(RedisCache.java:168)
- at org.springframework.cache.interceptor.AbstractCacheInvoker.doPut(AbstractCacheInvoker.java:87)
- at org.springframework.cache.interceptor.CacheAspectSupport$CachePutRequest.apply(CacheAspectSupport.java:837)
- at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:430)
- at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:345)
- at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:64)
- at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
- at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
- at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698)
- at com.kollybistes.core.services.EthereumService$$EnhancerBySpringCGLIB$$c3c3bd41.getWalletBalance(<generated>)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement