Skip to content

Commit

Permalink
fix compiler error and comments
Browse files Browse the repository at this point in the history
Signed-off-by: Kaituo Li <[email protected]>
  • Loading branch information
kaituo committed Jul 26, 2023
1 parent 9dddaa5 commit 50a5ff2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void runJob(ScheduledJobParameter scheduledJobParameter, JobExecutionCont
adTaskManager.refreshRealtimeJobRunTime(detectorId);
if (!(scheduledJobParameter instanceof Job)) {
throw new IllegalArgumentException(
"Job parameter is not instance of AnomalyDetectorJob, type: " + scheduledJobParameter.getClass().getCanonicalName()
"Job parameter is not instance of Job, type: " + scheduledJobParameter.getClass().getCanonicalName()
);
}
Job jobParameter = (Job) scheduledJobParameter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
import org.opensearch.common.xcontent.XContentHelper;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.common.bytes.BytesReference;
import org.opensearch.core.xcontent.MediaType;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.threadpool.ThreadPool;
Expand Down Expand Up @@ -202,7 +202,7 @@ private Optional<AnomalyResult> getAnomalyResult(DocWriteRequest<?> request) {
// we send IndexRequest previously
IndexRequest indexRequest = (IndexRequest) request;
BytesReference indexSource = indexRequest.source();
XContentType indexContentType = indexRequest.getContentType();
MediaType indexContentType = indexRequest.getContentType();
try (
XContentParser xContentParser = XContentHelper
.createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, indexSource, indexContentType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void maintenance() {
/**
* Used in delete workflow
*
* @param configId detector ID
* @param configId config ID
*/
@Override
public void clear(String configId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,21 @@ public void injectUserRolesFromConfig(ActionListener<Void> injectListener) {
return;
}

ActionListener<Optional<? extends Config>> getDetectorListener = ActionListener.wrap(detectorOp -> {
if (!detectorOp.isPresent()) {
ActionListener<Optional<? extends Config>> getConfigListener = ActionListener.wrap(configOp -> {
if (!configOp.isPresent()) {
injectListener.onFailure(new EndRunException(id, "Config is not available.", false));
return;
}
Config detector = detectorOp.get();
User userInfo = SecurityUtil.getUserFromConfig(detector, settings);
Config config = configOp.get();
User userInfo = SecurityUtil.getUserFromConfig(config, settings);
inject(userInfo.getName(), userInfo.getRoles());
injectListener.onResponse(null);
}, injectListener::onFailure);

// Since we are gonna read user from config, make sure the config exists and fetched from disk or cached memory
// We don't accept a passed-in Config because the caller might mistakenly not insert any user info in the
// constructed Config and thus poses risks. In the case, if the user is null, we will give admin role.
nodeStateManager.getConfig(id, context, getDetectorListener);
nodeStateManager.getConfig(id, context, getConfigListener);
}

public void injectUserRoles(User user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public void tearDown() throws Exception {
@Test
public void testRunJobWithWrongParameterType() {
expectedEx.expect(IllegalArgumentException.class);
expectedEx.expectMessage("Job parameter is not instance of AnomalyDetectorJob, type: ");
expectedEx.expectMessage("Job parameter is not instance of Job, type: ");

ScheduledJobParameter parameter = mock(ScheduledJobParameter.class);
when(jobParameter.getLockDurationSeconds()).thenReturn(null);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/opensearch/ad/ODFERestTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.commons.rest.SecureRestClientBuilder;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.core.xcontent.DeprecationHandler;
import org.opensearch.core.xcontent.MediaType;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.test.rest.OpenSearchRestTestCase;
Expand Down Expand Up @@ -156,7 +156,7 @@ protected RestClient buildClient(Settings settings, HttpHost[] hosts) throws IOE
@After
protected void wipeAllODFEIndices() throws IOException {
Response response = adminClient().performRequest(new Request("GET", "/_cat/indices?format=json&expand_wildcards=all"));
XContentType xContentType = XContentType.fromMediaType(response.getEntity().getContentType());
MediaType xContentType = MediaType.fromMediaType(response.getEntity().getContentType());
try (
XContentParser parser = xContentType
.xContent()
Expand Down

0 comments on commit 50a5ff2

Please sign in to comment.