File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
src/main/java/com/aliyun/oss/common/auth Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -52,8 +52,8 @@ public void setCredentials(Credentials creds) {
5252
5353 @ Override
5454 public InstanceProfileCredentials getCredentials () {
55- try {
56- if ( credentials == null || credentials . isExpired ()) {
55+ if ( credentials == null || credentials . isExpired ()) {
56+ try {
5757 lock .lock ();
5858 if (credentials == null || credentials .isExpired ()) {
5959 try {
@@ -63,7 +63,11 @@ public InstanceProfileCredentials getCredentials() {
6363 return null ;
6464 }
6565 }
66- } else if (credentials .willSoonExpire () && credentials .shouldRefresh ()) {
66+ } finally {
67+ lock .unlock ();
68+ }
69+ } else if (credentials .willSoonExpire () && credentials .shouldRefresh ()) {
70+ try {
6771 lock .lock ();
6872 if (credentials .willSoonExpire () && credentials .shouldRefresh ()) {
6973 try {
@@ -74,11 +78,12 @@ public InstanceProfileCredentials getCredentials() {
7478 LogUtils .logException ("EcsInstanceCredentialsFetcher.fetch Exception:" , e );
7579 }
7680 }
81+ } finally {
82+ lock .unlock ();
7783 }
78- return credentials ;
79- } finally {
80- lock .unlock ();
8184 }
85+
86+ return credentials ;
8287 }
8388
8489 private final String roleName ;
You can’t perform that action at this time.
0 commit comments