auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Object getNodeEntityById(ClassInfo classInfo, Object id) { Object node = primaryIndexNodeRegister.get(new LabelPrimaryId(classInfo, id)); if (node != null) { return node; } Deque<ClassInfo> queue = new LinkedList<>(classInfo.directSubclasses()); while (!queue.isEmpty()) { ClassInfo subClassInfo = queue.pop(); <START> if (subClassInfo.annotationsInfo().get(NodeEntity.class) ==null) { <END> continue; } node = primaryIndexNodeRegister.get(new LabelPrimaryId(subClassInfo, id)); if (node != null) { return node; } List<ClassInfo> deepSubClassInfos = subClassInfo.directSubclasses(); queue.addAll(deepSubClassInfos); } return null; }</code><technical_language>omitted blank == purpose, right? ;) jokes, means retrieve a node entity explicit @NodeEntity</technical_language>

Target:
public Object getNodeEntityById(ClassInfo classInfo, Object id) { if ((classInfo.isInterface() || classInfo.isAbstract()) && classInfo.annotationsInfo().get(NodeEntity.class) == null) { return null; } Object node = primaryIndexNodeRegister.get(new LabelPrimaryId(classInfo, id)); if (node != null) { return node; } Queue<ClassInfo> queue = new LinkedList<>(classInfo.directSubclasses()); while (!queue.isEmpty()) { ClassInfo subClassInfo = queue.poll(); node = primaryIndexNodeRegister.get(new LabelPrimaryId(subClassInfo, id)); if (node != null) { return node; } List<ClassInfo> deepSubClassInfos = subClassInfo.directSubclasses(); queue.addAll(deepSubClassInfos); } return null; }
Source:
<code>public Metacard getMetacardIfExistsOrNull(String id) throws UnsupportedQueryException, SourceUnavailableException, FederationException { Metacard metacard = null; Filter idFilter = filterBuilder.attribute(Metacard.ID).is().equalTo().text(id); Filter tagsFilter = filterBuilder.attribute(Metacard.TAGS).is().like().text("*"); Filter filter = filterBuilder.allOf(idFilter, tagsFilter); QueryResponse queryResponse = catalogFramework.query(new QueryRequestImpl(new QueryImpl(filter), false)); if (!queryResponse.getResults().isEmpty()) { Result result = queryResponse.getResults().get(0); <START> metacard = result.getMetacard(); <END> } return metacard; }</code><technical_language>return queryResponse.getResults().get(0).getMetacard() return null</technical_language>

Target:
public Metacard getMetacardIfExistsOrNull(String id) throws UnsupportedQueryException, SourceUnavailableException, FederationException { Filter idFilter = filterBuilder.attribute(Metacard.ID).is().equalTo().text(id); Filter tagsFilter = filterBuilder.attribute(Metacard.TAGS).is().like().text("*"); Filter filter = filterBuilder.allOf(idFilter, tagsFilter); QueryResponse queryResponse = catalogFramework.query(new QueryRequestImpl(new QueryImpl(filter), false)); if (!queryResponse.getResults().isEmpty()) { return queryResponse.getResults().get(0).getMetacard(); } return null; }
Source:
<code>public void correctlyPassesIfThereIsNotCorruption() { writeLogsOnServer(localStateLogComponents, 1, 10); remoteStateLogComponents.stream().forEach(server -> writeLogsOnServer(server, 1, 10)); List<CompletePaxosHistoryForNamespaceAndUseCase> historyForAll = paxosLogHistoryProvider.getHistory(); assertThat(HistoryAnalyzer.violatedCorruptionChecksForNamespaceAndUseCase( Iterables.getOnlyElement(historyForAll))) .isEqualTo(CorruptionCheckViolation.NONE); assertThat(HistoryAnalyzer.corruptionHealthReportForHistory(historyForAll) <START> .statusesToNamespaceAndUseCase() <END> .size()) .isEqualTo(0); }</code><technical_language>rename this violatingStatuses... that</technical_language>

Target:
public void correctlyPassesIfThereIsNotCorruption() { writeLogsOnServer(localStateLogComponents, 1, 10); remoteStateLogComponents.stream().forEach(server -> writeLogsOnServer(server, 1, 10)); List<CompletePaxosHistoryForNamespaceAndUseCase> historyForAll = paxosLogHistoryProvider.getHistory(); assertThat(HistoryAnalyzer.corruptionCheckViolationLevelForNamespaceAndUseCase( Iterables.getOnlyElement(historyForAll))) .isEqualTo(CorruptionCheckViolation.NONE); assertThat(HistoryAnalyzer.corruptionHealthReportForHistory(historyForAll) .violatingStatusesToNamespaceAndUseCase() .isEmpty()) .isTrue(); }
Source:
<code>public void testRecord003() throws CoreException { if (!isJRE14) { System.err.println("Test "+getName()+" requires a JRE 14"); return; } String source = "package pkg;\n" + <START> "public record Point(int param1, int param2) {\n" + <END> " public Point {\n" + " if (param1 > 5) {\n" + " System.out.println(\"error\");\n" + " }\n" + " }\n" + "\n" + " public Point(int a) {\n" + " this.param1 = 6;\n" + " this.param2 = 16;\n" + " a = 6;\n" + " }\n" + "}\n"; this.workingCopy = getWorkingCopy("/Converter14/src/X.java", true ); try { ASTNode node = buildAST(source, this.workingCopy); assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); } catch(UnsupportedOperationException e) { fail("Should not throw UnsupportedOperationException"); } }</code><technical_language>remove "public"</technical_language>

Target:
public void testRecord003() throws CoreException { if (!isJRE14) { System.err.println("Test "+getName()+" requires a JRE 14"); return; } String contents = "public record X(int param1, int param2) {\n" + " public X {\n" + " if (param1 > 5) {\n" + " System.out.println(\"error\");\n" + " }\n" + " }\n" + "\n" + " public X(int a) {\n" + " this.param1 = 6;\n" + " this.param2 = 16;\n" + " a = 6;\n" + " }\n" + "}\n"; this.workingCopy = getWorkingCopy("/Converter14/src/X.java", true ); IJavaProject javaProject = this.workingCopy.getJavaProject(); String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true); try { javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED); javaProject.setOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE); ASTNode node = buildAST( contents, this.workingCopy); assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); CompilationUnit compilationUnit = (CompilationUnit) node; assertProblemsSize(compilationUnit, 0); } finally { javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old); } }
Source:
<code>public static List<SessionData> from(Schedule schedule, OffsetTime now) { List<SessionData> sessionData = schedule.getSlots().stream() .filter(slot -> null != slot.getTalk()) .filter(slot -> slot.getTalk().getTalkType() != "BOF (Bird of a Feather)") .filter(slot -> OffsetTime.parse(slot.getToTime() + "Z").isAfter(now)) <START> .filter(slot -> !OffsetTime.parse(slot.getFromTime() + "Z").isBefore(now.plusMinutes(120))) <END> .collect(Collectors.groupingBy(slot -> slot.getRoomId())) .entrySet().stream() .map(entry -> entry.getValue().stream().findFirst()) .map(optional -> optional.orElse(null)) .map(slot -> new SessionData(slot.getRoomName(), slot.getTalk().getSpeakers().stream().map(ref -> ref.getName()).collect(Collectors.toList()), slot.getTalk().getTitle(), slot.getFromTime(), slot.isNotAllocated(), slot.getRoomSetup())) .sorted(SessionData.COMP) .collect(Collectors.toList()); System.out.println("Possible Next Sessions (" + sessionData.size() + "):\n " + sessionData); return sessionData; }</code><technical_language>I is wrong exclude talks start next 2 hours. Please verify this is intended</technical_language>

Target:
public static List<SessionData> from(Schedule schedule, OffsetTime now) { List<SessionData> sessionData = schedule.getSlots().stream() .filter(slot -> null != slot.getTalk()) .filter(slot -> slot.getTalk().getTalkType() != "BOF (Bird of a Feather)") .filter(slot -> OffsetTime.parse(slot.getToTime() + "Z").isAfter(now)) .filter(slot -> OffsetTime.parse(slot.getFromTime() + "Z").isBefore(now.plusMinutes(120))) .collect(Collectors.groupingBy(slot -> slot.getRoomId())) .entrySet().stream() .map(entry -> entry.getValue().stream().findFirst()) .map(optional -> optional.orElse(null)) .map(slot -> new SessionData(slot.getRoomName(), slot.getTalk().getSpeakers().stream().map(ref -> ref.getName()).collect(Collectors.toList()), slot.getTalk().getTitle(), slot.getFromTime(), slot.isNotAllocated(), slot.getRoomSetup())) .sorted(SessionData.COMP) .collect(Collectors.toList()); System.out.println("Possible Next Sessions (" + sessionData.size() + "):\n " + sessionData); return sessionData; }
Source:
<code>private CreateSchema(Optional<NodeLocation> location, QualifiedName schemaName, boolean notExists, List<Property> properties) { super(location); this.schemaName = requireNonNull(schemaName, "schemaName is null"); this.notExists = notExists; <START> this.properties = requireNonNull(properties, "properties is null"); <END> }</code><technical_language>This a defensive copy of list</technical_language>

Target:
private CreateSchema(Optional<NodeLocation> location, QualifiedName schemaName, boolean notExists, List<Property> properties) { super(location); this.schemaName = requireNonNull(schemaName, "schemaName is null"); this.notExists = notExists; this.properties = ImmutableList.copyOf(requireNonNull(properties, "properties is null")); }
Source:
<code>public Object readSqlResultRecord(ResultSet result) { CitationCollectionOrder citationCollectionOrder = null; String collectionId = null; int location = 0; String sectionType = null; String value = null; try { collectionId = result.getString(1); location = result.getInt(2); sectionType = result.getString(3); value = result.getString(4); <START> citationCollectionOrder = new CitationCollectionOrder(collectionId, location, CitationCollectionOrder.SectionType.HEADING1, value); <END> } catch (SQLException e) { M_log.debug("TripleReader: problem reading CitationCollectionOrder from result: collectionId(" + collectionId + ") location(" + location + ") sectionType(" + sectionType + ") value(" + value + ")"); return null; } return citationCollectionOrder; }</code><technical_language>parsing this enum</technical_language>

Target:
public Object readSqlResultRecord(ResultSet result) { CitationCollectionOrder citationCollectionOrder = null; String collectionId = null; int location = 0; CitationCollectionOrder.SectionType sectionType = null; String value = null; try { collectionId = result.getString(1); location = result.getInt(2); sectionType = CitationCollectionOrder.SectionType.valueOf(result.getString(3)); value = result.getString(4); citationCollectionOrder = new CitationCollectionOrder(collectionId, location, CitationCollectionOrder.SectionType.HEADING1, value); } catch (SQLException e) { M_log.debug("TripleReader: problem reading CitationCollectionOrder from result: collectionId(" + collectionId + ") location(" + location + ") sectionType(" + sectionType + ") value(" + value + ")"); return null; } return citationCollectionOrder; }
Source:
<code>public void shouldAcceptSv() throws Exception { <START> Variant input = new Variant("1", 1000, 1061, <END> "ATATATATATATATATATATATATATATATATATATATATATATATATATATATATATAT", "T"); Variant output = processor.process(input); assertEquals(Variant.VariantType.SV, input.getType()); assertNotNull(output); assertEquals(input, output); }</code><technical_language>coordinates 1000, 1059</technical_language>

Target:
public void shouldAcceptSv() throws Exception { Variant input = new Variant("1", 1000, 1059, "ATATATATATATATATATATATATATATATATATATATATATATATATATATATATATAT", "T"); Variant output = processor.process(input); assertEquals(Variant.VariantType.SV, input.getType()); assertNotNull(output); assertEquals(input, output); }
Source:
<code>public void ensureSubsequentRegistrationDoesNotFireActive() throws Throwable { final EventLoop eventLoop = mock(EventLoop.class); when(eventLoop.inEventLoop()).thenReturn(true); <START> when(eventLoop.unsafe()).thenReturn(new EventLoop.Unsafe() { <END> @Override public void register(Channel channel) { } @Override public void deregister(Channel channel) { } }); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { ((Runnable) invocationOnMock.getArgument(0)).run(); return null; } }).when(eventLoop).execute(any(Runnable.class)); final TestChannel channel = new TestChannel(eventLoop); ChannelInboundHandler handler = mock(ChannelInboundHandler.class); channel.pipeline().addLast(handler); registerChannel(channel); channel.unsafe().deregister(new DefaultChannelPromise(channel)); registerChannel(channel); verify(handler).handlerAdded(any(ChannelHandlerContext.class)); verify(handler, times(2)) .channelRegistered(any(ChannelHandlerContext.class)); verify(handler).channelActive(any(ChannelHandlerContext.class)); verify(handler).channelUnregistered(any(ChannelHandlerContext.class)); }</code><technical_language>I return mock(EventLoop.Unsafe.class)</technical_language>

Target:
public void ensureSubsequentRegistrationDoesNotFireActive() throws Throwable { final EventLoop eventLoop = mock(EventLoop.class); when(eventLoop.inEventLoop()).thenReturn(true); when(eventLoop.unsafe()).thenReturn(mock(EventLoop.Unsafe.class)); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { ((Runnable) invocationOnMock.getArgument(0)).run(); return null; } }).when(eventLoop).execute(any(Runnable.class)); final TestChannel channel = new TestChannel(eventLoop); ChannelInboundHandler handler = mock(ChannelInboundHandler.class); channel.pipeline().addLast(handler); registerChannel(channel); channel.unsafe().deregister(new DefaultChannelPromise(channel)); registerChannel(channel); verify(handler).handlerAdded(any(ChannelHandlerContext.class)); verify(handler, times(2)) .channelRegistered(any(ChannelHandlerContext.class)); verify(handler).channelActive(any(ChannelHandlerContext.class)); verify(handler).channelUnregistered(any(ChannelHandlerContext.class)); }
Source:
<code>public static void check(final HaxeVarDeclaration var, final AnnotationHolder holder) { HaxeFieldModel field = new HaxeFieldModel(var); if (field.isProperty()) { checkProperty(field, holder); } if (field.hasInitializer() && field.hasTypeTag()) { TypeTagChecker.check(field.getBasePsi(), field.getTypeTagPsi(), field.getInitializerPsi(), false, holder); } HashSet<HaxeClassModel> classSet = new HashSet<>(); HaxeClassModel fieldDeclaringClass = field.getDeclaringClass(); classSet.add(fieldDeclaringClass); while (fieldDeclaringClass != null) { fieldDeclaringClass = fieldDeclaringClass.getParentClass(); if (classSet.contains(fieldDeclaringClass)) { break; } else { classSet.add(fieldDeclaringClass); } if (fieldDeclaringClass != null) { for (HaxeFieldModel parentField : fieldDeclaringClass.getFields()) { if (parentField.getName().equals(field.getName())) { if (parentField.isStatic()) { holder.createWarningAnnotation(field.getNameOrBasePsi(), "Field '" + field.getName() + "' overrides a static field of a superclass."); } else { <START> holder.createErrorAnnotation(field.getBasePsi(), "Redefinition of variable '" + <END> field.getName() + "' in subclass is not allowed. Previously declared at '" + fieldDeclaringClass.getName() + "'."); } break; } } } } }</code><technical_language>previous code more readable. :/ Also, need '+' line</technical_language>

Target:
public static void check(final HaxeVarDeclaration var, final AnnotationHolder holder) { HaxeFieldModel field = new HaxeFieldModel(var); if (field.isProperty()) { checkProperty(field, holder); } if (field.hasInitializer() && field.hasTypeTag()) { TypeTagChecker.check(field.getBasePsi(), field.getTypeTagPsi(), field.getInitializerPsi(), false, holder); } HashSet<HaxeClassModel> classSet = new HashSet<>(); HaxeClassModel fieldDeclaringClass = field.getDeclaringClass(); classSet.add(fieldDeclaringClass); while (fieldDeclaringClass != null) { fieldDeclaringClass = fieldDeclaringClass.getParentClass(); if (classSet.contains(fieldDeclaringClass)) { break; } else { classSet.add(fieldDeclaringClass); } if (fieldDeclaringClass != null) { for (HaxeFieldModel parentField : fieldDeclaringClass.getFields()) { if (parentField.getName().equals(field.getName())) { String message; if (parentField.isStatic()) { message = HaxeBundle.message("haxe.semantic.static.field.override", field.getName()); holder.createWeakWarningAnnotation(field.getNameOrBasePsi(), message); } else { message = HaxeBundle.message("haxe.semantic.variable.redefinition", field.getName(), fieldDeclaringClass.getName()); holder.createErrorAnnotation(field.getBasePsi(), message); } break; } } } } }
Source:
<code>protected void fileNameValidation( final String fileName ) throws PlatformImportException { <START> if ( fileName != null && fileName.endsWith( ".xmi" ) ) { <END> throw new PlatformImportException( Messages.getString( "AnalysisService.ERROR_001_ANALYSIS_DATASOURCE_ERROR" ), PlatformImportException.PUBLISH_GENERAL_ERROR ); } }</code><technical_language>check filename ends .xml</technical_language>

Target:
protected void fileNameValidation( final String fileName ) throws PlatformImportException { if ( fileName != null && !fileName.endsWith( ".xml" ) ) { throw new PlatformImportException( Messages.getString( "AnalysisService.ERROR_001_ANALYSIS_DATASOURCE_ERROR" ), PlatformImportException.PUBLISH_GENERAL_ERROR ); } }
Source:
<code>public Observable<LeaderboardResponse> getLeaderboard(String userName, String duration, String category, String limit, String offset) { final String fetchLeaderboardUrlTemplate = wikiMediaTestToolforgeUrl <START> + "/leaderboard.py"; <END> String url = String.format(Locale.ENGLISH, fetchLeaderboardUrlTemplate, userName, duration, category, limit, offset); HttpUrl.Builder urlBuilder = HttpUrl.parse(url).newBuilder(); urlBuilder.addQueryParameter("user", userName); urlBuilder.addQueryParameter("duration", duration); urlBuilder.addQueryParameter("category", category); urlBuilder.addQueryParameter("limit", limit); urlBuilder.addQueryParameter("offset", offset); Timber.i("Url %s", urlBuilder.toString()); Request request = new Request.Builder() .url(urlBuilder.toString()) .build(); return Observable.fromCallable(() -> { Response response = okHttpClient.newCall(request).execute(); if (response != null && response.body() != null && response.isSuccessful()) { String json = response.body().string(); if (json == null) { return new LeaderboardResponse(); } Timber.d("Response for leaderboard is %s", json); try { return gson.fromJson(json, LeaderboardResponse.class); } catch (Exception e) { return new LeaderboardResponse(); } } return new LeaderboardResponse(); }); }</code><technical_language>put a constant</technical_language>

Target:
public Observable<LeaderboardResponse> getLeaderboard(String userName, String duration, String category, String limit, String offset) { final String fetchLeaderboardUrlTemplate = wikiMediaTestToolforgeUrl + LEADERBOARD_END_POINT; String url = String.format(Locale.ENGLISH, fetchLeaderboardUrlTemplate, userName, duration, category, limit, offset); HttpUrl.Builder urlBuilder = HttpUrl.parse(url).newBuilder(); urlBuilder.addQueryParameter("user", userName); urlBuilder.addQueryParameter("duration", duration); urlBuilder.addQueryParameter("category", category); urlBuilder.addQueryParameter("limit", limit); urlBuilder.addQueryParameter("offset", offset); Timber.i("Url %s", urlBuilder.toString()); Request request = new Request.Builder() .url(urlBuilder.toString()) .build(); return Observable.fromCallable(() -> { Response response = okHttpClient.newCall(request).execute(); if (response != null && response.body() != null && response.isSuccessful()) { String json = response.body().string(); if (json == null) { return new LeaderboardResponse(); } Timber.d("Response for leaderboard is %s", json); try { return gson.fromJson(json, LeaderboardResponse.class); } catch (Exception e) { return new LeaderboardResponse(); } } return new LeaderboardResponse(); }); }
Source:
<code>public DataStoreTransaction beginTransaction() { <START> if (queryEngine.getClass().equals(SQLQueryEngine.class)) { <END> return new SQLAggregationDataStoreTransaction(queryEngine, cache, queryLogger); } throw new IllegalStateException("Unknown type of Query Engine"); }</code><technical_language>this here? I want AggregationDataStore subclasses</technical_language>

Target:
public DataStoreTransaction beginTransaction() { return new AggregationDataStoreTransaction(queryEngine, cache, queryLogger); }
Source:
<code>HashCode computeTemplateHash(String soyFile) { URL u = templates.get(soyFile); checkState(u != null, "Missing Soy template %s", soyFile); <START> try (InputStream in = u.openStream()) { <END> byte[] buf = new byte[4096]; Hasher h = Hashing.sha1().newHasher(); for (int n; (n = in.read(buf)) > 0;) { h.putBytes(buf, 0, n); } return h.hash(); } catch (IOException e) { throw new IllegalStateException("Missing Soy template " + soyFile, e); } }</code><technical_language>Guava do more of work: Hasher h = Hashing.sha1().newHasher(); try (InputStream is = u.openStream(); OutputStream os = Funnels.asOutputStream(h)) { ByteStreams.copy(is, os); } return h.hash();</technical_language>

Target:
HashCode computeTemplateHash(String soyFile) { URL u = templates.get(soyFile); checkState(u != null, "Missing Soy template %s", soyFile); Hasher h = Hashing.sha1().newHasher(); try (InputStream is = u.openStream(); OutputStream os = Funnels.asOutputStream(h)) { ByteStreams.copy(is, os); } catch (IOException e) { throw new IllegalStateException("Missing Soy template " + soyFile, e); } return h.hash(); }
Source:
<code>private boolean propagate() { <START> block.predecessors().stream() .map(programStateByBlock::get) .map(programStateAtBlock -> programStateAtBlock.out) .forEach(predecessorOuts -> in = join(in, predecessorOuts)); <END> Map<Symbol, Set<Expression>> newOut = new HashMap<>(in); block.elements().forEach(element -> updateProgramState(element, newOut)); boolean outHasChanged = !newOut.equals(out); out = newOut; return outHasChanged; }</code><technical_language>suggestion block.predecessors().forEach(predecessor -> in = join(in, programStateByBlock.get(predecessor).out));</technical_language>

Target:
private boolean propagate() { block.predecessors().forEach(predecessor -> in = join(in, programStateByBlock.get(predecessor).out)); Map<Symbol, Set<Expression>> newOut = new HashMap<>(in); block.elements().forEach(element -> updateProgramState(element, newOut)); boolean outHasChanged = !newOut.equals(out); out = newOut; return outHasChanged; }
Source:
<code>private static void transformMappedBy(Attribute attribute, Map<String, Attribute> newAttributes) { <START> if (attribute.getMappedBy() != null) { <END> String mappedByAttrId = attribute.getMappedBy().getIdentifier(); if (newAttributes.containsKey(mappedByAttrId)) { attribute.setMappedBy(newAttributes.get(mappedByAttrId)); } } }</code><technical_language>suggestion if (attribute.isMappedBy()) {</technical_language>

Target:
private static void transformMappedBy(Attribute attribute, Map<String, Attribute> newAttributes) { if (attribute.isMappedBy()) { @SuppressWarnings("ConstantConditions") String mappedByAttrId = attribute.getMappedBy().getIdentifier(); if (newAttributes.containsKey(mappedByAttrId)) { attribute.setMappedBy(newAttributes.get(mappedByAttrId)); } } }
Source:
<code>void registerMetricsIfNecessary(TableReference tableRef) { SlidingTimeWindowReservoir reservoir = new SlidingTimeWindowReservoir(7, TimeUnit.DAYS); Histogram slidingWeek = new Histogram(reservoir); <START> String deletesMetric = MetricRegistry.name(SweepMetrics.class, "deletes", tableRef.getQualifiedName()); <END> registerMetricIfNotExists(deletesMetric, slidingWeek); }</code><technical_language>in metric name this is deletes week. want pull out separate method for reuse</technical_language>

Target:
void registerMetricsIfNecessary(TableReference tableRef) { forAllMetrics(metric -> metric.registerForTable(tableRef)); }
Source:
<code>public static ApplicationRecord getInstalledAppRecord() { <START> SqlStorage<ApplicationRecord> storage = <END> CommCareApplication._().getGlobalStorage(ApplicationRecord.class); for (Persistable p : storage) { ApplicationRecord r = (ApplicationRecord) p; if (r.getStatus() == ApplicationRecord.STATUS_INSTALLED) { return r; } } return null; }</code><technical_language>Yeah, migrations occur DB is opened for time, need open Global App DB's get UserDB handles, feel comfortable assuming Global DB migrations commited</technical_language>

Target:
public static ApplicationRecord getInstalledAppRecord() { SqlStorage<ApplicationRecord> storage = CommCareApplication._().getGlobalStorage(ApplicationRecord.class); for (Persistable p : storage) { ApplicationRecord r = (ApplicationRecord) p; if (r.getStatus() == ApplicationRecord.STATUS_INSTALLED && r.resourcesValidated()) { return r; } } return null; }
Source:
<code>public ModuleOptions interpolate(final Map<String, String> raw) throws BindException { MapBindingResult bindingResult = new MapBindingResult(new HashMap<String, String>(), "options"); for (String provided : raw.keySet()) { if (!options.containsKey(provided)) { bindingResult.addError(new FieldError("options", provided, String.format( "Module option '%s' does not exist", provided))); } } if (bindingResult.hasErrors()) { throw new BindException(bindingResult); } ModuleOptions moduleOptions = new ModuleOptions() { @Override public EnumerablePropertySource<?> asPropertySource() { return new EnumerablePropertySource<Object>(this.toString(), this) { @Override public Object getProperty(String name) { ModuleOption option = options.get(name); if (option != null) { String provided = raw.get(name); if (provided != null) { validateByType(option, provided); return provided; } else { <START> if (option.getDefaultValue() != null) { <END> validateByType(option, option.getDefaultValue().toString()); } return option.getDefaultValue(); } } else { return null; } } @Override public String[] getPropertyNames() { return options.keySet().toArray(new String[options.size()]); } }; } }; for (String name : options.keySet()) { moduleOptions.asPropertySource().getProperty(name); } return moduleOptions; }</code><technical_language>I this moved add() method L41</technical_language>

Target:
public ModuleOptions interpolate(final Map<String, String> raw) throws BindException { MapBindingResult bindingResult = new MapBindingResult(new HashMap<String, String>(), "options"); for (String provided : raw.keySet()) { if (!options.containsKey(provided)) { bindingResult.addError(new FieldError("options", provided, String.format( "Module option '%s' does not exist", provided))); } } if (bindingResult.hasErrors()) { throw new BindException(bindingResult); } ModuleOptions moduleOptions = new ModuleOptions() { @Override public EnumerablePropertySource<?> asPropertySource() { return new EnumerablePropertySource<Object>(this.toString(), this) { @Override public Object getProperty(String name) { ModuleOption option = options.get(name); if (option != null) { String provided = raw.get(name); if (provided != null) { validateByType(option, provided); return provided; } else { return option.getDefaultValue(); } } else { return null; } } @Override public String[] getPropertyNames() { return options.keySet().toArray(new String[options.size()]); } }; } }; PropertySource<?> ps = moduleOptions.asPropertySource(); for (String name : options.keySet()) { ps.getProperty(name); } return moduleOptions; }
Source:
<code>public void jwksRegenerationTask() { <START> if (configurationService.get().getEnableJwksGeneration()) { <END> LOG.trace("Delete jwks from object if not present in storage..."); if (keyGeneratorService.getKeysFromStorage() == null) { LOG.trace("Jwks not present in storage. Resetting jwks in object to null..."); keyGeneratorService.setKeys(null); } LOG.trace("Generating jwks if missing in storage or expired..."); keyGeneratorService.getKeys(); } }</code><technical_language>Minor early return is more readable due ifs if (!configurationService.get().getEnableJwksGeneration()) { return; }</technical_language>

Target:
public void jwksRegenerationTask() { ScheduledExecutorService scheduledExecutorService = CoreUtils.createExecutor(); scheduledExecutorService.scheduleWithFixedDelay(new Runnable() { public void run() { if (!configurationService.get().getEnableJwksGeneration()) { return; } LOG.trace("Delete jwks from object if not present in storage..."); if (keyGeneratorService.getKeysFromStorage() == null) { LOG.trace("Jwks not present in storage. Resetting jwks in object to null..."); keyGeneratorService.setKeys(null); } LOG.trace("Generating jwks if missing in storage or expired..."); keyGeneratorService.getKeys(); } }, configurationService.get().getJwksRegenerationIntervalInHours(), configurationService.get().getJwksRegenerationIntervalInHours(), TimeUnit.HOURS); }
Source:
<code>public String sendRestoreFromDeletionOperation(String userid, Collection<PID> unmarked) { Element contentEl = createAtomEntry(userid, unmarked.iterator().next(), CDRActions.RESTORE_FROM_DELETION); <START> Element mark = new Element("markForDeletion", CDR_MESSAGE_NS); <END> contentEl.addContent(mark); Element subjects = new Element("subjects", CDR_MESSAGE_NS); mark.addContent(subjects); for (PID sub : unmarked) { subjects.addContent(new Element("pid", CDR_MESSAGE_NS).setText(sub.getRepositoryPath())); } Document msg = contentEl.getDocument(); sendMessage(msg); return getMessageId(msg); }</code><technical_language>Element name match name of action</technical_language>

Target:
public String sendRestoreFromDeletionOperation(String userid, Collection<PID> unmarked) { Element contentEl = createAtomEntry(userid, unmarked.iterator().next(), CDRActions.RESTORE_FROM_DELETION); Element mark = new Element("restoreFromDeletion", CDR_MESSAGE_NS); contentEl.addContent(mark); Element subjects = new Element("subjects", CDR_MESSAGE_NS); mark.addContent(subjects); for (PID sub : unmarked) { subjects.addContent(new Element("pid", CDR_MESSAGE_NS).setText(sub.getRepositoryPath())); } Document msg = contentEl.getDocument(); sendMessage(msg); return getMessageId(msg); }
Source:
<code>public synchronized Location getLocation(Context context) { if (mLocation == null) { start(context, GOOGLE_API_CONNECT_TIMEOUT, false); if (isPlayServicesConnected()) { if (isLocationManagerConnected()) { stopLocationUpdatesWithoutPlayServices(); } try { mLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); } catch (SecurityException e) { Log.e(TAG, "Appium Settings has no access to location permission", e); } } else if (isLocationManagerConnected() || mGoogleApiClient != null) { <START> if (mGoogleApiClient != null && !isLocationManagerConnected()) { <END> startLocationUpdatesWithoutPlayServices(); } if (mLocationManager != null) { try { mLocation = mLocationManager.getLastKnownLocation(mLocationProvider); } catch (SecurityException e) { Log.e(TAG, String.format("Appium Settings has no access to %s location permission", mLocationProvider), e); } } } } return mLocation; }</code><technical_language>mLocationManager is null if mGoogleApiClient initialized. startLocationUpdatesWithoutPlayServices() throws NPE in case</technical_language>

Target:
public synchronized Location getLocation(Context context) { if (mLocation != null) { return mLocation; } final boolean forceStart = hasAccessToLocationServices != null && !hasAccessToLocationServices; start(context, GOOGLE_API_CONNECT_TIMEOUT, forceStart); if (isPlayServicesConnected()) { if (isLocationManagerConnected()) { stopLocationUpdatesWithoutPlayServices(); } try { mLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); hasAccessToLocationServices = true; } catch (SecurityException e) { hasAccessToLocationServices = false; Log.e(TAG, "Appium Settings has no access to location permission", e); } } else if (isLocationManagerConnected() || mGoogleApiClient != null) { if (mGoogleApiClient != null && !isLocationManagerConnected()) { mLocationManager = (LocationManager) context.getSystemService(LOCATION_SERVICE); if (mLocationManager != null) { startLocationUpdatesWithoutPlayServices(); } } if (mLocationManager != null && mLocationProvider != null) { try { mLocation = mLocationManager.getLastKnownLocation(mLocationProvider); hasAccessToLocationServices = true; } catch (SecurityException e) { hasAccessToLocationServices = false; Log.e(TAG, String.format("Appium Settings has no access to %s location permission", mLocationProvider), e); } } } return mLocation; }
Source:
<code>public Sequence<Cursor> makeCursors(Filter filter, Interval interval, QueryGranularity gran, boolean descending) { Interval actualInterval = interval; long minDataTimestamp = getMinTime().getMillis(); long maxDataTimestamp = getMaxTime().getMillis(); final Interval dataInterval = new Interval( minDataTimestamp, gran.next(gran.truncate(maxDataTimestamp)) ); if (!actualInterval.overlaps(dataInterval)) { return Sequences.empty(); } if (actualInterval.getStart().isBefore(dataInterval.getStart())) { actualInterval = actualInterval.withStart(dataInterval.getStart()); } if (actualInterval.getEnd().isAfter(dataInterval.getEnd())) { actualInterval = actualInterval.withEnd(dataInterval.getEnd()); } Filter[] filters = Filters.partitionWithBitmapSupport(filter); final Offset offset; <START> if (filters[0] == null) { <END> offset = new NoFilterOffset(0, index.getNumRows(), descending); } else { final ColumnSelectorBitmapIndexSelector selector = new ColumnSelectorBitmapIndexSelector( index.getBitmapFactoryForDimensions(), index ); offset = new BitmapOffset(selector.getBitmapFactory(), filters[0].getBitmapIndex(selector), descending); } return Sequences.filter( new CursorSequenceBuilder( index, actualInterval, gran, offset, filters[1], minDataTimestamp, maxDataTimestamp, descending ).build(), Predicates.<Cursor>notNull() ); }</code><technical_language>is this size guaranteed 1? If so, add a check for that</technical_language>

Target:
public Sequence<Cursor> makeCursors(Filter filter, Interval interval, QueryGranularity gran, boolean descending) { Interval actualInterval = interval; long minDataTimestamp = getMinTime().getMillis(); long maxDataTimestamp = getMaxTime().getMillis(); final Interval dataInterval = new Interval( minDataTimestamp, gran.next(gran.truncate(maxDataTimestamp)) ); if (!actualInterval.overlaps(dataInterval)) { return Sequences.empty(); } if (actualInterval.getStart().isBefore(dataInterval.getStart())) { actualInterval = actualInterval.withStart(dataInterval.getStart()); } if (actualInterval.getEnd().isAfter(dataInterval.getEnd())) { actualInterval = actualInterval.withEnd(dataInterval.getEnd()); } final Filter[] filters = Filters.partitionWithBitmapSupport(filter); final Filter bitmapFilter = filters == null ? null : filters[0]; final Filter valuesFilter = filters == null ? null : filters[1]; final Offset offset; if (bitmapFilter == null) { offset = new NoFilterOffset(0, index.getNumRows(), descending); } else { final ColumnSelectorBitmapIndexSelector selector = new ColumnSelectorBitmapIndexSelector( index.getBitmapFactoryForDimensions(), index ); offset = new BitmapOffset(selector.getBitmapFactory(), bitmapFilter.getBitmapIndex(selector), descending); } return Sequences.filter( new CursorSequenceBuilder( index, actualInterval, gran, offset, valuesFilter, minDataTimestamp, maxDataTimestamp, descending ).build(), Predicates.<Cursor>notNull() ); }
Source:
<code><START> public static LiveVariables analyze(CFG cfg, boolean includeFields) { <END> LiveVariables liveVariables = new LiveVariables(cfg, includeFields); Map<CFG.Block, Set<Symbol>> kill = new HashMap<>(); Map<CFG.Block, Set<Symbol>> gen = new HashMap<>(); for (CFG.Block block : liveVariables.cfg.reversedBlocks()) { Set<Symbol> blockKill = new HashSet<>(); Set<Symbol> blockGen = new HashSet<>(); liveVariables.processBlockElements(block, blockKill, blockGen); kill.put(block, blockKill); gen.put(block, blockGen); } liveVariables.analyzeCFG(liveVariables.in, kill, gen); if (!liveVariables.out.get(liveVariables.cfg.reversedBlocks().get(0)).isEmpty()) { throw new IllegalStateException("Out of exit block should be empty"); } for (Map.Entry<CFG.Block, Set<Symbol>> blockSetEntry : liveVariables.out.entrySet()) { blockSetEntry.setValue(ImmutableSet.copyOf(blockSetEntry.getValue())); } return liveVariables; }</code><technical_language>Design wise : I public static methods analyze analyzeWithFields call this method privately flag set correctly</technical_language>

Target:
private static LiveVariables analyze(CFG cfg, boolean includeFields) { LiveVariables liveVariables = new LiveVariables(cfg, includeFields); Map<CFG.Block, Set<Symbol>> kill = new HashMap<>(); Map<CFG.Block, Set<Symbol>> gen = new HashMap<>(); for (CFG.Block block : liveVariables.cfg.reversedBlocks()) { Set<Symbol> blockKill = new HashSet<>(); Set<Symbol> blockGen = new HashSet<>(); liveVariables.processBlockElements(block, blockKill, blockGen); kill.put(block, blockKill); gen.put(block, blockGen); } liveVariables.analyzeCFG(liveVariables.in, kill, gen); if (!liveVariables.out.get(liveVariables.cfg.reversedBlocks().get(0)).isEmpty()) { throw new IllegalStateException("Out of exit block should be empty"); } for (Map.Entry<CFG.Block, Set<Symbol>> blockSetEntry : liveVariables.out.entrySet()) { blockSetEntry.setValue(ImmutableSet.copyOf(blockSetEntry.getValue())); } return liveVariables; }
Source:
<code>protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_path_tracker); ButterKnife.bind(this); <START> if (!CheckSelfPermissionAndRequest <END> .checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) || !CheckSelfPermissionAndRequest .checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)) { CheckSelfPermissionAndRequest .requestPermission(this, Manifest.permission.ACCESS_FINE_LOCATION, 100, "Location Permission is necessary for this feature", "Location Permission is necessary for this feature", "Permission Denied"); } else { start.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (buildLocationEnableDialog()) { service.startLogging(); } } }); stop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { service.stopLogging(); } }); } showBackButton(); }</code><technical_language>This is good implementation get user runtime permission implemented onActivityResult, do know, is user response. this <LINK_1> standard class for requesting runtime permission. refer implementation <LINK_0></technical_language>

Target:
protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_path_tracker); ButterKnife.bind(this); start.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (checkPermissionAndRequest()) { service.startLogging(); } } }); stop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { service.stopLogging(); } }); showBackButton(); }
Source:
<code>public ValidationResult checkObjectCode(String chartOfAccountsCode, String objectCodeParm) { ValidationResult validationResult = new ValidationResult(true, new ArrayList<String>()); ObjectCode objectCode = objectCodeService.getByPrimaryIdForCurrentYear(chartOfAccountsCode, objectCodeParm); <START> if (objectCode == null || objectCode.toString().isEmpty()) { <END> validationResult.setValid(false); validationResult.addMessage(ConcurConstants.AccountingStringValidationErrorMessages.ERROR_OBJ_CD_DOES_NOT_EXIST); } else if (!objectCode.isActive()) { validationResult.setValid(false); validationResult.addMessage(ConcurConstants.AccountingStringValidationErrorMessages.ERROR_OBJ_CD_INACTIVE); } return validationResult; }</code><technical_language>I if this code cleaner not, this block is pretty similar of accounting string components. I extract a method parameters (Inactivatable object, String missingMessage, String inactiveMessage) common logic for of them</technical_language>

Target:
public ValidationResult checkObjectCode(String chartOfAccountsCode, String objectCodeParm) { ObjectCode objectCode = objectCodeService.getByPrimaryIdForCurrentYear(chartOfAccountsCode, objectCodeParm); return checkMissingOrInactive(objectCode, MessageFormat.format(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_EXISTENCE), ConcurConstants.AccountingStringFieldNames.OBJECT_CODE), MessageFormat.format(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_INACTIVE), ConcurConstants.AccountingStringFieldNames.OBJECT_CODE)); }
Source:
<code>public void testCaasUrl() { <START> Supplier<String> orgIdSupplier = new OrganisationIdForAccount(api); <END> String expectedPath = "/caas/2.4/6ac1e746-b1ea-4da5-a24e-caf1a978789d/server/0896551e-4fe3-4450-a627-ad5548e7e83a?clone=trevor-test2&desc=trevor-description2"; String updatedPath = new OrganisationIdFilter(orgIdSupplier).injectOrganisationId( "/caas/2.4/server/0896551e-4fe3-4450-a627-ad5548e7e83a?clone=trevor-test2&desc=trevor-description2"); assertEquals(updatedPath, expectedPath); }</code><technical_language>return a mock supplier for this test: Suppliers.ofInstance("6ac1e746-b1ea-4da5-a24e-caf1a978789d/"). This need overhead of starting a mock server, creating context, etc</technical_language>

Target:
public void testCaasUrl() { String expectedPath = "/caas/2.4/6ac1e746-b1ea-4da5-a24e-caf1a978789d/server/0896551e-4fe3-4450-a627-ad5548e7e83a?clone=trevor-test2&desc=trevor-description2"; String updatedPath = new OrganisationIdFilter(orgIdSupplier).injectOrganisationId( "/caas/2.4/server/0896551e-4fe3-4450-a627-ad5548e7e83a?clone=trevor-test2&desc=trevor-description2"); assertEquals(updatedPath, expectedPath); }
Source:
<code>public AmbryCapacityUnitQuotaEnforcer(QuotaSource quotaSource) { <START> this.quotaSource = quotaSource; <END> allowRecommendation = new AmbryEnforcementRecommendation(false, 0, AmbryCapacityUnitQuotaEnforcer.class.getSimpleName(), 200); }</code><technical_language>This AllowEverythingEnforcer</technical_language>

Target:
public AmbryCapacityUnitQuotaEnforcer(QuotaSource quotaSource) { this.quotaSource = quotaSource; allowRecommendation = new AmbryEnforcementRecommendation(false, 0, AmbryCapacityUnitQuotaEnforcer.class.getSimpleName(), 200, new RequestCost(null, null)); }
Source:
<code>public void close() { File dir = new File("."); for (int i = 0; i < dir.list().length; i++) { <START> File f = dir.listFiles()[i]; <END> if (f.getAbsolutePath().endsWith(".class")) { f.delete(); } } }</code><technical_language>move dir.listFiles out of this for loop, listFiles called multiple times</technical_language>

Target:
public void close() { File dir = new File("."); File[] dirFiles = dir.listFiles(); for (int i = 0; i < dir.list().length; i++) { File f = dirFiles[i]; if (f.getAbsolutePath().endsWith(".class")) { f.delete(); } } }
Source:
<code>private static String updateFileSystemProperties(@Nullable String fileSystemProperties, String accessID, String accessKey, String authenticationMethod, String enableEncryption) { Map<String, String> providedProperties; if (fileSystemProperties == null) { providedProperties = new HashMap<>(); } else { providedProperties = GSON.fromJson(fileSystemProperties, MAP_STRING_STRING_TYPE); } boolean encryptionEnabled = enableEncryption != null && enableEncryption.equalsIgnoreCase("True"); if (authenticationMethod != null && authenticationMethod.equalsIgnoreCase("Access Credentials")) { providedProperties.put("fs.s3n.awsAccessKeyId", accessID); providedProperties.put("fs.s3n.awsSecretAccessKey", accessKey); <START> if (encryptionEnabled) { <END> providedProperties.put("fs.s3n.server-side-encryption-algorithm", ENCRYPTION_VALUE); } } else if (authenticationMethod != null && authenticationMethod.equalsIgnoreCase("IAM")) { if (encryptionEnabled) { providedProperties.put("fs.s3a.server-side-encryption-algorithm", ENCRYPTION_VALUE); } } return GSON.toJson(providedProperties); }</code><technical_language>this extracted parent if statement need repeated</technical_language>

Target:
private static String updateFileSystemProperties(@Nullable String fileSystemProperties, String accessID, String accessKey, String authenticationMethod, String enableEncryption) { Map<String, String> providedProperties; if (fileSystemProperties == null) { providedProperties = new HashMap<>(); } else { providedProperties = GSON.fromJson(fileSystemProperties, MAP_STRING_STRING_TYPE); } boolean encryptionEnabled = enableEncryption != null && enableEncryption.equalsIgnoreCase("True"); if (authenticationMethod != null && authenticationMethod.equalsIgnoreCase(ACCESS_CREDENTIALS)) { providedProperties.put(ACCESS_KEY, accessID); providedProperties.put(SECRET_KEY, accessKey); if (encryptionEnabled) { providedProperties.put(S3N_ENCRYPTION, ENCRYPTION_VALUE); } } else if (authenticationMethod != null && authenticationMethod.equalsIgnoreCase(IAM) && encryptionEnabled) { providedProperties.put(S3A_ENCRYPTION, ENCRYPTION_VALUE); } return GSON.toJson(providedProperties); }
Source:
<code>public void handleDefaultDeviceResponse(final String deviceIdentification, final String organisationIdentification, final String correlationUid, final String messageType, final ResponseMessageResultType deviceResult, final OsgpException exception) { LOGGER.info("handleDefaultDeviceResponse for MessageType: {}", messageType); ResponseMessageResultType result = deviceResult; OsgpException osgpException = exception; if (deviceResult == ResponseMessageResultType.NOT_OK && exception == null) { LOGGER.error("Incorrect response received, exception should not be null when result is not ok"); osgpException = new TechnicalException(ComponentType.DOMAIN_TARIFF_SWITCHING, "An unknown error occurred"); } if (deviceResult == ResponseMessageResultType.OK && exception != null) { LOGGER.error("Incorrect response received, result should be set to not ok when exception is not null"); result = ResponseMessageResultType.NOT_OK; } <START> this.webServiceResponseMessageSender.send(ResponseMessage.newResponseMessageBuilder() <END> .withCorrelationUid(correlationUid).withOrganisationIdentification(organisationIdentification) .withDeviceIdentification(deviceIdentification).withResult(result).withOsgpException(osgpException) .build()); }</code><technical_language>Extract building of ResponseMessage variable (in eclipse, select text, right-click > refactor > extract local variable / select code + shift+alt+L). This code a bit more readable, especially passing in other besides ResponseMessage</technical_language>

Target:
public void handleDefaultDeviceResponse(final String deviceIdentification, final String organisationIdentification, final String correlationUid, final String messageType, final ResponseMessageResultType deviceResult, final OsgpException exception) { LOGGER.info("handleDefaultDeviceResponse for MessageType: {}", messageType); ResponseMessageResultType result = deviceResult; OsgpException osgpException = exception; if (deviceResult == ResponseMessageResultType.NOT_OK && exception == null) { LOGGER.error("Incorrect response received, exception should not be null when result is not ok"); osgpException = new TechnicalException(ComponentType.DOMAIN_TARIFF_SWITCHING, "An unknown error occurred"); } if (deviceResult == ResponseMessageResultType.OK && exception != null) { LOGGER.error("Incorrect response received, result should be set to not ok when exception is not null"); result = ResponseMessageResultType.NOT_OK; } ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder() .withCorrelationUid(correlationUid).withOrganisationIdentification(organisationIdentification) .withDeviceIdentification(deviceIdentification).withResult(result).withOsgpException(osgpException) .build(); this.webServiceResponseMessageSender.send(responseMessage); }
Source:
<code>public Host findDefaultHost(User user, boolean respectFrontendRoles) throws DotSecurityException, DotDataException { Host host; try{ host = (hostCache.getDefaultHost()!=null) ? hostCache.getDefaultHost() : getOrCreateDefaultHost(); APILocator.getPermissionAPI().checkPermission(host, PermissionLevel.READ, user); return host; } catch (DotSecurityException | DotDataException e) { throw e; <START> } catch (Exception e) { <END> throw new DotRuntimeException(e.getMessage(), e); } }</code><technical_language>log message</technical_language>

Target:
public Host findDefaultHost(User user, boolean respectFrontendRoles) throws DotSecurityException, DotDataException { Host host; try{ host = (hostCache.getDefaultHost()!=null) ? hostCache.getDefaultHost() : getOrCreateDefaultHost(); APILocator.getPermissionAPI().checkPermission(host, PermissionLevel.READ, user); return host; } catch (DotSecurityException | DotDataException e) { Logger.warn(HostAPIImpl.class, "Error trying to het default host:" + e.getMessage()); throw e; } catch (Exception e) { throw new DotRuntimeException(e.getMessage(), e); } }