File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
ml-algorithms/src/main/java/org/opensearch/ml/engine/encryptor Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 2727import java .util .concurrent .CountDownLatch ;
2828import java .util .concurrent .atomic .AtomicReference ;
2929
30+ import static java .util .concurrent .TimeUnit .SECONDS ;
3031import static org .opensearch .ml .common .CommonValue .MASTER_KEY ;
3132import static org .opensearch .ml .common .CommonValue .ML_CONFIG_INDEX ;
3233
@@ -111,7 +112,7 @@ private void initMasterKey() {
111112 client .get (getRequest , new LatchedActionListener (ActionListener .<GetResponse >wrap (r -> {
112113 if (r .isExists ()) {
113114 String masterKey = (String ) r .getSourceAsMap ().get (MASTER_KEY );
114- setMasterKey ( masterKey ) ;
115+ this . masterKey = masterKey ;
115116 } else {
116117 exceptionRef .set (new ResourceNotFoundException ("ML encryption master key not initialized yet" ));
117118 }
@@ -122,6 +123,13 @@ private void initMasterKey() {
122123 }
123124 } else {
124125 exceptionRef .set (new ResourceNotFoundException ("ML encryption master key not initialized yet" ));
126+ latch .countDown ();
127+ }
128+
129+ try {
130+ latch .await (5 , SECONDS );
131+ } catch (InterruptedException e ) {
132+ throw new IllegalStateException (e );
125133 }
126134
127135 if (exceptionRef .get () != null ) {
@@ -132,5 +140,8 @@ private void initMasterKey() {
132140 throw new MLException (exceptionRef .get ());
133141 }
134142 }
143+ if (masterKey == null ) {
144+ throw new ResourceNotFoundException ("ML encryption master key not initialized yet" );
145+ }
135146 }
136147}
You can’t perform that action at this time.
0 commit comments