
연관 게시물 [Java] 자바에서의 스레드 안전(Thread Safe)과 모니터(monitor) 자바에서의 Thread-Safe 1. Lock synchronized 아래 코드는 Synchronized 키워드를 사용하여 스레드의 안전성을 보장했다. @ThreadSafe public class Lock { @GuardedBy("this") private int nextValue; public synchronized int getNext() { r mag1c.tistory.com Thread Safe 스레드 안전(thread safety)은 멀티 스레드 프로그래밍에서 일반적으로 어떤 함수나 변수, 혹은 객체가 여러 스레드로부터 동시에 접근이 이루어져도 프로그램의 실행에 문제가 없음을 뜻한다. 보다 엄밀하게는..
![[Java] 스태틱 블록(Static block) (초기화 블록)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FdzDhff%2FbtsheD3efGr%2FAAAAAAAAAAAAAAAAAAAAAB0h7Ip7XZiQ2nYrCx2-lYkJz6433hdGQEyi4DWSBncv%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1756652399%26allow_ip%3D%26allow_referer%3D%26signature%3DsDIwAaXtL5Ts2l8aRUREBvPf7pA%253D)
기존에 내가 사용하고 자주 봤던 static이 붙은 것들은 public static int a; public static void main(String[] args){} 이정도인데, 업무 내에서 아래와 같은 코드를 발견했다. public Conf { static { loadConfiguration(); } } 얼추 인스턴스가 생성될 때 아래의 메서드를 실행하는 것 정도만 알겠는데 정확히 어떤 것인지 모르겠다. 개념정리를 해놓고 언제든 활용할 수 있도록 해보자. 초기화 블록 class Class { static int Field = 10; // 클래스 변수의 명시적 초기화 int Field2 = 20; // 인스턴스 변수의 명시적 초기화 } 필드는 위와같은 형태로 초기화가 진행되는데, 초기화 블록을 활용하..
![[SpringBoot/WebSocket+SocketJS] CORS 설정 시 에러 (When allowCredentials is true, allowedOrigins cannot contain the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" response header. To allow credentials to a set of or..](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FsKVLn%2FbtsgCCYbFj9%2FAAAAAAAAAAAAAAAAAAAAAIS9NHMBxIR15LiyeBkAxiBqgqaZo8NDSvF-cCKqlSK5%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1756652399%26allow_ip%3D%26allow_referer%3D%26signature%3DyMLJtktfvUlPyvdACK8wVuS7Xs8%253D)
에러 메세지 When allowCredentials is true, allowedOrigins cannot contain the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" response header. To allow credentials to a set of origins, list them explicitly or consider using "allowedOriginPatterns" instead. 원인 CORS설정 시 allowedCredentials true와, allowedOrigins "*"를 같이 사용할 수 없다. 해결 에러 메세지에 친절하게 나와있다. allowedOrigins("*") 대신..
![[SpringBoot/AWS S3] Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied;](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FcAn2Tu%2FbtsgDKt7WlU%2FAAAAAAAAAAAAAAAAAAAAAPHU7LHHgUgzD34V5RZh6k4AyviLcl_K7gB3oAZWzcTF%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1756652399%26allow_ip%3D%26allow_referer%3D%26signature%3DJv5r3wR2a7CggXgtGsNb%252FEg4XSU%253D)
에러 메세지 Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; 에러 원인 단순 읽어보면 접근이 막혔다는 것 같다. KEY가 노출되어 접근이 제한됐을 경우 재생성해주어야 하는 것 같고. 나의 경우 단순히 S3을 생성하고 이미지 업로드를 시도해보자마자 생겼던 터라 버킷 내부 설정들을 꼼꼼히 들여다 보았는데, 액세스 차단설정이 되어있었다. 나와 같은 경우가 아니라면 아래 링크들을 참조해 보는것도 좋을 것 같다. [AWS CLI] Github에 Access Key 노출 IAM User AccessDenied cloudest.oopy.io Spring S3 업로드 S3 파일 업로드 코드 velog.io 해결 위의 액세스 차..
![[Java/Selenium] org.openqa.selenium.WebDriverException: java.net.ConnectionException: Failed to connect to localhost/0:0:0:0:0:0:0:1:port](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbjIvXM%2FbtsgUsTwRfe%2FAAAAAAAAAAAAAAAAAAAAAGKfMlobbjvQYAuKyoF2H-3UTbZEii-RCSdY64JkgMvG%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1756652399%26allow_ip%3D%26allow_referer%3D%26signature%3Dg36P%252FU2FAgWdhhodi0775BJ9ekg%253D)
에러 메세지 org.openqa.selenium.WebDriverException: java.net.ConnectionException: Failed to connect to localhost/0:0:0:0:0:0:0:1:port 원인 정확한 원인은 모르겠어서 구글링을 아무리 이리저리 해봤으나 해결하지 못했고 위의 사진처럼 저런식으로 IPv4를 받아와서 해결했다는 사람도 있다고 하길래 해봤지만 나는 실패했다. 그거 외엔 아무리 구글링을 해봐도 시도해볼만한 거리가 없어서 고민하던 중에 공식문서를 보게 됐고 The Selenium Browser Automation Project Selenium automates browsers. That's it! www.selenium.dev selenium 사용에 있어 ..
![[SpringBoot/AWS S3] com.amazonaws.services.s3.model.AmazonS3Exception: The bucket does not allow ACLs (Service: Amazon S3; Status Code: 400; Error Code: AccessControlListNotSupported; Request ID:](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbKjBmk%2FbtsgKnRT0wb%2FAAAAAAAAAAAAAAAAAAAAAArki5WQFp8J8zJk-1JRmFKM1iPPZx6U4dZD5CfZRiNE%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1756652399%26allow_ip%3D%26allow_referer%3D%26signature%3Ds6gtZdNeycVZc3CG5OKdjd0QTqU%253D)
에러 메세지 The bucket does not allow ACLs (Service: Amazon S3; Status Code: 400; Error Code: AccessControlListNotSupported; Request ID: "?"; S3 Extended Request ID: "?"=; Proxy: null) 원인 버킷의 ACL이 비활성화되어 있음. 해결 활성화 시키기
![[AWS S3] AWS S3 Access denied(Console 빨간줄)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FdShDaa%2FbtsgL9Nmhwq%2FAAAAAAAAAAAAAAAAAAAAAMuS9iwjEaq4UjkmI6AYvcO9sYtrxJQ8_YwUj-W8MJF3%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1756652399%26allow_ip%3D%26allow_referer%3D%26signature%3DeyhvkRHggNYILHbQu0rtplYNRMs%253D)
에러 메세지 Access denied Eclipse로 AWS S3 업로드 작업 중 위의 Access denied 딱 요 글자만 빨간색으로 콘솔에 찍힘. 해결 버킷 - 권한 - 버킷 정책에 아래와 같이 작성 { "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1405592139000", "Effect": "Allow", "Principal": "*", "Action": "s3:*", "Resource": [ "arn:aws:s3:::버킷명/*", "arn:aws:s3:::버킷명" ] } ] }
![[SpringBoot/Thymeleaf] java.lang.NumberFormatException : Failed to convert value of type 'java.lang.String' to required type 'int'; For input string: "{idx}"](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbLiDZF%2FbtsgECbrq9B%2FAAAAAAAAAAAAAAAAAAAAACurtVSwEBxfEl_tHInEdYjuMgRe8X_QDFYAcYzniCYh%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1756652399%26allow_ip%3D%26allow_referer%3D%26signature%3DPsVrYGMa5EWtqCFL7meWLUWsanU%253D)
에러 메세지 Failed to convert value of type 'java.lang.String' to required type 'int'; For input string: "{idx}" 에러 원인 AWS S3로 이미지 업로드를 구현하는 과정에서 발생했고 String형태로 넘어가서 int로 받지를 못하는 듯 하다 @ResponseBody @PostMapping("/img/{idx}") public String img_modify(@PathVariable int idx, @RequestParam("imgfile") MultipartFile imgfile, UserDTO dto) throws IOException { System.out.println(imgfile.getName()); System.ou..