728x90

Shop 상에서 Login 이 지속적으로 풀리는 현상이 발생

해당 부분에서 내 Android 기기로 접근했을 때의 Bearer 를 땃고, 이걸 기반으로 accessToken 값으로 활용해서 End-Point에 던져보기로 했다

 

맨 처음에는 유효하지 않은 토큰이라고 resultMsg 가 return 되길래 나자신 뭘잘못했는가 생각하다가, end-point 주소가 잘못됬었다는 것을 기억하고 때려박으니 던져서 납치해오는 방법에 대해서 문제가 생긴것으로 생각된다.

 

Android Side 에서 request  -> Spring 에서 hook -> Shop 의 API 단에 때려박고 -> Shop 내부의 DB 에 접근하는 것으로 보이는데, 신기하게도 Spring 서버를 재시작 시키면 4~6시간은 정상적으로 작동되는 것으로 보아 뭔가가 있다고 판단함

728x90
[Rest][2023-08-02 18:39:02][ERROR][PostingController.java][lambda$doFindPostingActivity$5(92)] : readPosting
org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type for: public abstract boolean net.infobank.moyamo.repository.PostingRepository.isPostingOwner(long,java.lang.Long)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:229)
        at com.sun.proxy.$Proxy237.isPostingOwner(Unknown Source)
        at net.infobank.moyamo.service.PostingService.findPostingActivity(PostingService.java:1831)
        at net.infobank.moyamo.service.PostingService$$FastClassBySpringCGLIB$$72b2a0db.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
        at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692)
        at net.infobank.moyamo.service.PostingService$$EnhancerBySpringCGLIB$$886f7a7f.findPostingActivity(<generated>)
        at net.infobank.moyamo.controller.PostingController.lambda$doFindPostingActivity$4(PostingController.java:91)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:750)

 

Handling

The error message you are encountering (AopInvocationException: Null return value from advice does not match primitive return type) suggests that a method with a primitive return type (boolean in this case) is returning null. Since primitives cannot be null, this results in an exception.

Here's a brief rundown of what might be happening:

  1. Method Signature: The method isPostingOwner(long, java.lang.Long) in the PostingRepository interface is declared with a return type of boolean.
  2. Proxy Invocation: During the invocation, some AOP advice (such as a transactional aspect) may be being applied to this method.
  3. Null Return: For some reason, this method is returning null (possibly from a repository implementation or advice method), which is not compatible with the primitive boolean return type.

Here's how you can potentially resolve this:

1. Check the Repository Implementation

Ensure that the method's implementation in the corresponding repository class is not returning null. It should return a boolean value (true or false).

2. Check the AOP Advice

If there is any AOP (Aspect-Oriented Programming) advice being applied to the method, make sure that it's not altering the return value to null. Examine any aspects that might be affecting the method, including transactional aspects.

3. Change the Return Type (if applicable)

If it is acceptable for the method to indicate an absence of a value, consider changing the return type of the method from the primitive boolean to the wrapper class Boolean. This will allow the method to return null. Note that this will require handling the null value in the calling code.

Example:

javaCopy code
public abstract Boolean isPostingOwner(long id, java.lang.Long ownerId);

4. Exception Handling

If the null return is expected in some situations (like when some data is not found), consider adding proper exception handling in the method or its caller to deal with these scenarios gracefully.

By focusing on these areas, you should be able to track down the cause of the exception and resolve it. Make sure to thoroughly test your changes to ensure they don't introduce other issues.

 

 

 

JPOL 상에서 일치하지 않는 return type을 확인해서 boolean 에서 Boolean 으로 변경

@Query("select p.owner.id from Posting p where p.id = :postingId and p.owner.id = :userId")
Boolean isPostingOwner(@Param("postingId") long postingId, @Param("userId") Long userId);

 

추가적으로 null Pointer Exception handling

if(isWatch == null) {
    isWatch = !commentRepository.findDistinctRecipientByMentionUserIds(id, Collections.singletonList(user.getId())).isEmpty();
    Boolean isOwner = postingRepository.isPostingOwner(id, user.getId());
    isWatch = isWatch || (isOwner != null && isOwner);
}

 

을 했지만 문제발생으로 인한 JPQL 변경으로 처리

@Query("select case when count(p) > 0 then true else false end from Posting p where p.id = :postingId and p.owner.id = :userId")
Boolean isPostingOwner(@Param("postingId") long postingId, @Param("userId") Long userId);
728x90

AWS assigns the following unique identifiers to each AWS account:

AWS account ID

A 12-digit number, such as 012345678901, that uniquely identifies an AWS account. Many AWS resources include the account ID in their Amazon Resource Names (ARNs). The account ID portion distinguishes resources in one account from the resources in another account. If you're an AWS Identity and Access Management (IAM) user, you can sign in to the AWS Management Console using either the account ID or account alias. While account IDs, like any identifying information, should be used and shared carefully, they are not considered secret, sensitive, or confidential information.

Canonical user ID

An alpha-numeric identifier, such as 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be, that is an obfuscated form of the AWS account ID. You can use this ID to identify an AWS account when granting cross-account access to buckets and objects using Amazon Simple Storage Service (Amazon S3). You can retrieve the canonical user ID for your AWS account as either the root user or an IAM user.

You must be authenticated with AWS to view these identifiers.

Warning

Do not provide your AWS credentials (including passwords and access keys) to a third party that needs your AWS account identifiers to share AWS resources with you. Doing so would give them the same access to the AWS account that you have.

Finding your AWS account ID

You can find the AWS account ID using either the AWS Management Console or the AWS Command Line Interface (AWS CLI). In the console, the location of the account ID depends on whether you're signed in as the root user or an IAM user. The account ID is the same whether you're signed in as the root user or an IAM user.

Finding your account ID as the root user

 
  • AWS Management Console
  • AWS CLI & SDKs

To find your AWS account ID using the AWS CLI

Minimum permissions

To perform the following steps, you must have at least the following IAM permissions:

  • When you run the command as the root user, you don't need any IAM permissions.

Use the get-caller-identity command as follows.

 
$ aws sts get-caller-identity \
    --query Account \
    --output text
123456789012
728x90

In calling API Gateway with cloud functions, Terminal message show me like below:

Although API gateway was assigned to PUBLIC ZONE and No API Key, means authentication do not needed, happened problem and postman was same thing.

But do not error response after connecting SSL VPN, Be exactly, If API gateway zone setting was "Public", must be accessed by someone and somewhere End-Point.


Trouble Shooting - Guide Document modifying planned

+ Recent posts