edu.umd.cs.findbugs.annotations.SuppressFBWarnings Java Examples
The following examples show how to use
edu.umd.cs.findbugs.annotations.SuppressFBWarnings.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XidImpl.java From ballerina-message-broker with Apache License 2.0 | 6 votes |
@SuppressFBWarnings(value = {"EI_EXPOSE_REP2", "EI_EXPOSE_REP2"}, justification = "Data holder of global transaction identifier and branch qualifier") public XidImpl(int formatId, byte[] branchQualifier, byte[] globalTransactionId) { this.branchQualifier = branchQualifier; this.formatId = formatId; this.globalTransactionId = globalTransactionId; }
Example #2
Source File: AppendRequest.java From waltz with Apache License 2.0 | 6 votes |
@SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "internal class") public AppendRequest( ReqId reqId, long clientHighWaterMark, int[] writeLockRequest, int[] readLockRequest, int[] appendLockRequest, int header, byte[] data, int checksum ) { super(reqId); this.clientHighWaterMark = clientHighWaterMark; this.writeLockRequest = writeLockRequest; this.readLockRequest = readLockRequest; this.appendLockRequest = appendLockRequest; this.header = header; this.data = data; this.checksum = checksum; }
Example #3
Source File: NillableReader.java From arctic-sea with Apache License 2.0 | 5 votes |
@Override @SuppressFBWarnings("NP_NONNULL_PARAM_VIOLATION") protected void begin() throws XMLStreamException, DecodingException { Optional<String> attr = attr(W3CConstants.QN_XSI_NIL); if (attr.isPresent() && attr.get().equals("true")) { List<QName> attributeNames = getPossibleNilReasonAttributes(); Iterable<Optional<String>> attributes = attr(attributeNames); Iterable<String> reasons = Optional.presentInstances(attributes); this.nillable = Nillable.nil(Iterables.getFirst(reasons, null)); } else { this.nillable = Nillable.of(delegate(getDelegate())); } }
Example #4
Source File: CipherAgentImpl.java From GDH with MIT License | 5 votes |
/** * Decrypt an encrypted byte array with a key and initial vector * * @param encryptedBytes * the byte array to decrypt * @param iv * the initial vector. Must be a random 128 bit value and the * same one used in encryption * @param key * the key for decryption * * @return the decrypted string */ @SuppressFBWarnings("UC_USELESS_OBJECT") public String decrypt(byte[] encryptedBytes, byte[] iv, SecretKey key) throws InvalidKeyException, InvalidAlgorithmParameterException, IOException { byte[] buf = new byte[Constants.CIPHER_SIZE]; ByteArrayOutputStream outputStream = null; IvParameterSpec ivspec = new IvParameterSpec(iv); decryptCipher.init(Cipher.DECRYPT_MODE, key, ivspec); outputStream = new ByteArrayOutputStream(); ByteArrayInputStream inStream = new ByteArrayInputStream(encryptedBytes); CipherInputStream cipherInputStream = new CipherInputStream(inStream, decryptCipher); int bytesRead = 0; while ((bytesRead = cipherInputStream.read(buf)) >= 0) { outputStream.write(buf, 0, bytesRead); } cipherInputStream.close(); return outputStream.toString(StandardCharsets.UTF_8.name()); }
Example #5
Source File: ThriftIdlGenerator.java From drift with Apache License 2.0 | 5 votes |
@SuppressWarnings("NonShortCircuitBooleanExpression") @SuppressFBWarnings("NS_DANGEROUS_NON_SHORT_CIRCUIT") private boolean verifyField(ThriftType type) { ThriftProtocolType proto = type.getProtocolType(); if (proto == ThriftProtocolType.SET || proto == ThriftProtocolType.LIST) { return verifyElementType(type.getValueTypeReference()); } if (proto == ThriftProtocolType.MAP) { return verifyElementType(type.getKeyTypeReference()) & verifyElementType(type.getValueTypeReference()); } if (knownTypes.contains(type)) { return true; } if (includes.containsKey(type)) { usedIncludedTypes.add(type); return true; } if (recursive) { // recursive but type is unknown - add it to the list and recurse thriftTypes.add(type); return verifyStruct(type, true); } return false; }
Example #6
Source File: SweHelper.java From arctic-sea with Apache License 2.0 | 5 votes |
@SuppressFBWarnings("BC_VACUOUS_INSTANCEOF") private List<String> createBlock(SweAbstractDataComponent elementType, Time phenomenonTime, String phenID, Value<?> value) { if (elementType instanceof SweDataRecord) { SweDataRecord elementTypeRecord = (SweDataRecord) elementType; List<String> block = new ArrayList<>(elementTypeRecord.getFields().size()); if (!(value instanceof NilTemplateValue)) { elementTypeRecord.getFields().forEach(field -> { if (field.getElement() instanceof SweTime || field.getElement() instanceof SweTimeRange) { block.add(DateTimeHelper.format(phenomenonTime)); } else if (field.getElement() instanceof SweAbstractDataComponent && field.getElement().getDefinition().equals(phenID)) { block.add(value.getValue().toString()); } else if (field.getElement() instanceof SweObservableProperty) { block.add(phenID); } }); } return block; } String exceptionMsg = String.format("Type of ElementType is not supported: %s", elementType != null ? elementType.getClass().getName() : "null"); LOGGER.debug(exceptionMsg); throw new IllegalArgumentException(exceptionMsg); }
Example #7
Source File: DockerLogManager.java From carnotzet with Apache License 2.0 | 5 votes |
/** * Ensures that a listener is listening to the logs of a container, from a given time **/ @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED") private void ensureCapturingContainerLogs(Container container, Instant since, LogListener listener) { ContainerListener key = new ContainerListener(container, listener); Flowable stream = captureStreams.get(key); if (stream != null) { return; } List<String> command = getLogCommand(since, listener, container); log.debug("Scheduling new log capture flowable for container [{}] and listener [{}], command is [{}]", container, listener, Joiner.on(' ').join(command)); try { Process dockerCliProcess = new ProcessBuilder(command.toArray(new String[command.size()])).start(); Flowable<String> stdOutLines = flowableInputStreamScanner(dockerCliProcess.getInputStream()).subscribeOn(Schedulers.newThread()); Flowable<String> stdErrLines = flowableInputStreamScanner(dockerCliProcess.getErrorStream()).subscribeOn(Schedulers.newThread()); Flowable<String> allLines = stdOutLines.mergeWith(stdErrLines); Flowable<LogEvent> allEvents = allLines.map(s -> new LogEvent(container.getServiceName(), container.getReplicaNumber(), s)); allEvents.subscribe(listener::accept, Throwable::printStackTrace, () -> captureStreams.remove(key)); captureStreams.put(key, allEvents); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #8
Source File: EolHelper.java From butterfly with MIT License | 5 votes |
/** * Finds out what EOL character(s) are used by the specified text file. * If the specified file has no EOL characters null will be returned, and if more than * one type of EOL character(s) are used, the very first EOL occurrence will be returned. * If the file is empty, it returns null. * * @param textFile file to be analyzed based on its EOL character(s) * @return the very first occurrence of EOL used in the specified text file, or null, * if none is found * @throws IOException if any IO exception happens when opening and reading the text file */ @SuppressFBWarnings("DM_DEFAULT_ENCODING") public static String findEol(File textFile) throws IOException { if (textFile == null) { throw new IllegalArgumentException("Text file object cannot be null"); } if (!textFile.isFile()) { throw new IllegalArgumentException("Text file is not a file"); } if (textFile.length() == 0) { return null; } EolBufferedReader eolBufferedReader = null; try { eolBufferedReader = new EolBufferedReader(new BufferedReader(new FileReader(textFile))); String line = eolBufferedReader.readLineKeepEol(); return getEndEol(line); } finally { if (eolBufferedReader != null) eolBufferedReader.close(); } }
Example #9
Source File: CapabilitiesDocumentDecoder.java From arctic-sea with Apache License 2.0 | 5 votes |
@Override @SuppressFBWarnings("NP_LOAD_OF_KNOWN_NULL_VALUE") public GetCapabilitiesResponse decode(CapabilitiesDocument cd) throws DecodingException { if (cd != null) { GetCapabilitiesResponse response = new GetCapabilitiesResponse(); OwsCapabilities capabilities = (OwsCapabilities) decodeXmlObject(cd.getCapabilities()); response.setCapabilities(capabilities); response.setXmlString(cd.xmlText(getXmlOptions())); return response; } throw new UnsupportedDecoderInputException(this, cd); }
Example #10
Source File: ProductSync.java From commercetools-sync-java with Apache License 2.0 | 5 votes |
@SuppressFBWarnings("NP_NONNULL_PARAM_VIOLATION") // https://github.com/findbugsproject/findbugs/issues/79 @Nonnull private CompletionStage<Void> applyCallbackAndCreate(@Nonnull final ProductDraft productDraft) { return syncOptions .applyBeforeCreateCallBack(productDraft) .map(draft -> productService .createProduct(draft) .thenAccept(productOptional -> { if (productOptional.isPresent()) { readyToResolve.add(productDraft.getKey()); statistics.incrementCreated(); } else { statistics.incrementFailed(); } }) ) .orElse(CompletableFuture.completedFuture(null)); }
Example #11
Source File: DiscoveryEnabledServerPredicate.java From spring-cloud-ribbon-extensions with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE") protected boolean doApply(PredicateKey input) { return input.getServer() instanceof DiscoveryEnabledServer && doApply((DiscoveryEnabledServer) input.getServer()); }
Example #12
Source File: OperationMessage.java From testgrid with Apache License 2.0 | 5 votes |
/** * Read back persisted data from a file into the message queue * * @return true if success, else false */ @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") private synchronized boolean recoverOperationQueue() { try { String persistedResult = FileUtil.readFile(PERSISTED_FILE_PATH, this.operationId.concat(".txt")); double contentLength = persistedResult.length(); this.messageQueue.add(persistedResult); this.persisted = false; this.contentLength = contentLength; } catch (TestGridException e) { logger.error("Unable read data from a file for operation id " + this.operationId, e); return false; } return removePersistedFile(); }
Example #13
Source File: TinkererSDK.java From testgrid with Apache License 2.0 | 5 votes |
/** * Get a list of agent for given set of test plans * * @param testPlanId The test plan id * @return List of agents for given test plan id */ @SuppressFBWarnings("SIC_INNER_SHOULD_BE_STATIC_ANON") public List<Agent> getAgentListByTestPlanId(String testPlanId) { Client client = ClientBuilder.newClient(); Response response = client.target(this.tinkererHost + "test-plan/" + testPlanId) .path("agents") .request() .header(HttpHeaders.AUTHORIZATION, this.authenticationToken) .get(); Type listType = new TypeToken<List<Agent>>() { }.getType(); return new Gson().fromJson(response.readEntity(String.class), listType); }
Example #14
Source File: ModifierFormat.java From freecol with GNU General Public License v2.0 | 5 votes |
@SuppressFBWarnings(value="NP_LOAD_OF_KNOWN_NULL_VALUE") private static String getSourceName(FreeColObject source) { if (source == null) return getUnknownValue(); String result = null; if (result == null && source instanceof Nameable) { result = ((Nameable)source).getName(); if (result != null && result.isEmpty()) result = null; } if (result == null && source instanceof Named) { result = Messages.getName((Named)source); if (result.isEmpty()) result = null; } if (result == null) result = Messages.getName(source.getId()); return result; }
Example #15
Source File: GetObservationResponseDocumentDecoder.java From arctic-sea with Apache License 2.0 | 5 votes |
@Override @SuppressFBWarnings("NP_LOAD_OF_KNOWN_NULL_VALUE") public GetObservationResponse decode(GetObservationResponseDocument gord) throws DecodingException { if (gord != null) { GetObservationResponse response = new GetObservationResponse(); setService(response); setVersions(response); GetObservationResponseType gort = gord.getGetObservationResponse(); response.setExtensions(parseExtensibleResponse(gort)); response.setObservationCollection(ObservationStream.of(parseObservtions(gort))); return response; } throw new UnsupportedDecoderInputException(this, gord); }
Example #16
Source File: PutMediaManager.java From amazon-kinesis-video-streams-producer-sdk-java with Apache License 2.0 | 5 votes |
@SuppressFBWarnings("OBL_UNSATISFIED_OBLIGATION") public void sendTestMkvStream(final ClientConfiguration config) throws Exception { @WillClose final InputStream testMkvStream = new FileInputStream("testdata/test_depth_cal.mkv"); final Long streamStartTime = 1498511782000L; //TODO: Add as a cmd line parameter. PutMediaClient.builder().putMediaDestinationUri(config.getStreamUri()).mkvStream(testMkvStream).streamName(config.getStreamName()).timestamp(streamStartTime).fragmentTimecodeType(ABSOLUTE).signWith(signer).receiveAcks(new StreamConsumer(config.getApiName())).build().putMediaInBackground(); }
Example #17
Source File: DbMetaDataHelper.java From syndesis with Apache License 2.0 | 5 votes |
@SuppressFBWarnings("OBL_UNSATISFIED_OBLIGATION") /* default */ List<SqlParam> getOutputColumnInfo( final String sqlSelectStatement) throws SQLException { List<SqlParam> paramList = new ArrayList<>(); try (PreparedStatement stmt = createPreparedStatement(sqlSelectStatement); ResultSet resultSet = stmt.executeQuery();) { ResultSetMetaData metaData = resultSet.getMetaData(); if (metaData.getColumnCount()>0){ for (int i=1; i<=metaData.getColumnCount(); i++) { SqlParam param = new SqlParam(metaData.getColumnName(i)); param.setJdbcType(JDBCType.valueOf(metaData.getColumnType(i))); paramList.add(param); } } return paramList; } }
Example #18
Source File: AquaMicroScannerBuilder.java From aqua-microscanner-plugin with Apache License 2.0 | 5 votes |
@SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE") // No idea why this is needed private void archiveArtifacts(Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener) throws java.lang.InterruptedException { ArtifactArchiver artifactArchiver = new ArtifactArchiver("scanout*"); artifactArchiver.perform(build, workspace, launcher, listener); ArtifactArchiver styleArtifactArchiver = new ArtifactArchiver("styles.css"); styleArtifactArchiver.perform(build, workspace, launcher, listener); }
Example #19
Source File: TopicSensors.java From ksql-fork-with-deep-learning-function with Apache License 2.0 | 5 votes |
@SuppressFBWarnings("FE_FLOATING_POINT_EQUALITY") public String formatted() { if (value == Math.round(value)) { return String.format("%16s:%10.0f", name, value); } else { return String.format("%16s:%10.2f", name, value); } }
Example #20
Source File: IntegrationTest.java From warnings-ng-plugin with MIT License | 5 votes |
@SuppressFBWarnings(value = "LG", justification = "Setting the logger here helps to clean up the console log for tests") static WebClient create(final JenkinsRule jenkins, final boolean isJavaScriptEnabled) { WebClient webClient = jenkins.createWebClient(); webClient.setCssErrorHandler(new SilentCssErrorHandler()); java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.SEVERE); webClient.setIncorrectnessListener((s, o) -> { }); webClient.setJavaScriptEnabled(isJavaScriptEnabled); webClient.setJavaScriptErrorListener(new IntegrationTestJavaScriptErrorListener()); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); webClient.getCookieManager().setCookiesEnabled(isJavaScriptEnabled); webClient.getOptions().setCssEnabled(isJavaScriptEnabled); webClient.getOptions().setDownloadImages(false); webClient.getOptions().setUseInsecureSSL(true); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.getOptions().setPrintContentOnFailingStatusCode(false); return webClient; }
Example #21
Source File: KolobokeLongIntHashMap.java From coding-snippets with MIT License | 5 votes |
@SuppressFBWarnings(value = "EC_UNRELATED_TYPES_USING_POINTER_EQUALITY") @Override public String toString() { if (KolobokeLongIntHashMap.EntryView.this.isEmpty()) return "[]"; StringBuilder sb = new StringBuilder(); int elementCount = 0; int mc = modCount(); long free = freeValue; long[] keys = set; int[] vals = values; for (int i = (keys.length) - 1; i >= 0; i--) { long key; if ((key = keys[i]) != free) { sb.append(' '); sb.append(key); sb.append('='); sb.append(vals[i]); sb.append(','); if ((++elementCount) == 8) { int expectedLength = (sb.length()) * ((size()) / 8); sb.ensureCapacity((expectedLength + (expectedLength / 2))); } } } if (mc != (modCount())) throw new ConcurrentModificationException(); sb.setCharAt(0, '['); sb.setCharAt(((sb.length()) - 1), ']'); return sb.toString(); }
Example #22
Source File: KolobokeLongIntHashMap.java From coding-snippets with MIT License | 5 votes |
@SuppressFBWarnings(value = "EC_UNRELATED_TYPES_USING_POINTER_EQUALITY") @Override public String toString() { if (KolobokeLongIntHashMap.ValueView.this.isEmpty()) return "[]"; StringBuilder sb = new StringBuilder(); int elementCount = 0; int mc = modCount(); long free = freeValue; long[] keys = set; int[] vals = values; for (int i = (keys.length) - 1; i >= 0; i--) { if ((keys[i]) != free) { sb.append(' ').append(vals[i]).append(','); if ((++elementCount) == 8) { int expectedLength = (sb.length()) * ((size()) / 8); sb.ensureCapacity((expectedLength + (expectedLength / 2))); } } } if (mc != (modCount())) throw new ConcurrentModificationException(); sb.setCharAt(0, '['); sb.setCharAt(((sb.length()) - 1), ']'); return sb.toString(); }
Example #23
Source File: AxivionSuite.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Checks whether the given path is a correct os path. * * @param basedir * path to check * * @return {@link FormValidation#ok()} is a valid url */ @SuppressFBWarnings("PATH_TRAVERSAL_IN") public FormValidation doCheckBasedir(@QueryParameter final String basedir) { try { if (!basedir.contains("$")) { // path with a variable cannot be checked at this point Paths.get(basedir); } } catch (InvalidPathException e) { return FormValidation.error("You have to provide a valid path."); } return FormValidation.ok(); }
Example #24
Source File: FindBugsMessages.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Initializes the messages map. */ @SuppressWarnings("all") @SuppressFBWarnings("DE_MIGHT_IGNORE") public void initialize() { try { loadMessages("messages.xml", messages, shortMessages); loadMessages("fb-contrib-messages.xml", messages, shortMessages); loadMessages("find-sec-bugs-messages.xml", messages, shortMessages); loadMessages("messages_fr.xml", frMessages, frShortMessages); loadMessages("messages_ja.xml", jaMessages, jaShortMessages); } catch (Exception ignored) { // ignore failures } }
Example #25
Source File: PropertyTable.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Creates a new instance of {@link PropertyTable}. * * @param page * the whole details HTML page * @param property * the property tab to extract */ @SuppressFBWarnings("BC") public PropertyTable(final HtmlPage page, final String property) { super(page); title = getTitleOfTable(page, property); DomElement propertyElement = page.getElementById(property); assertThat(propertyElement).isInstanceOf(HtmlTable.class); HtmlTable table = (HtmlTable) propertyElement; List<HtmlTableRow> tableHeaderRows = table.getHeader().getRows(); assertThat(tableHeaderRows).hasSize(1); HtmlTableRow header = tableHeaderRows.get(0); List<HtmlTableCell> cells = header.getCells(); assertThat(cells).hasSize(3); propertyName = cells.get(0).getTextContent(); assertThat(cells.get(1).getTextContent()).isEqualTo("Total"); assertThat(cells.get(2).getTextContent()).isEqualTo("Distribution"); List<HtmlTableBody> bodies = table.getBodies(); assertThat(bodies).hasSize(1); List<HtmlTableRow> contentRows = bodies.get(0).getRows(); for (HtmlTableRow row : contentRows) { List<HtmlTableCell> rowCells = row.getCells(); rows.add(new PropertyRow(rowCells)); } }
Example #26
Source File: StageResultHandlerTest.java From warnings-ng-plugin with MIT License | 5 votes |
@Test @SuppressWarnings("ConstantConditions") @SuppressFBWarnings(value = "DP_DO_INSIDE_DO_PRIVILEGED", justification = "Needed to keep `FlowNode.getPersistentAction` from failing. " + "We can't mock the method directly because it's final.") void pipelineHandlerShouldSetBuildResultAndAddWarningAction() throws IllegalAccessException, IllegalArgumentException, NoSuchFieldException { Run run = mock(Run.class); FlowNode flowNode = mock(FlowNode.class); Field actions = FlowNode.class.getDeclaredField("actions"); actions.setAccessible(true); actions.set(flowNode, new CopyOnWriteArrayList<>()); StageResultHandler pipelineHandler = new PipelineResultHandler(run, flowNode); pipelineHandler.setResult(Result.UNSTABLE, MESSAGE); verify(run).setResult(Result.UNSTABLE); verify(flowNode).addOrReplaceAction(refEq(new WarningAction(Result.UNSTABLE).withMessage(MESSAGE))); pipelineHandler.setResult(Result.FAILURE, MESSAGE); verify(flowNode).addOrReplaceAction(refEq(new WarningAction(Result.FAILURE).withMessage(MESSAGE))); }
Example #27
Source File: DemoAppBase.java From waltz with Apache License 2.0 | 5 votes |
@SuppressFBWarnings(value = "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING", justification = "internal use") protected void createClientHighWaterMarkTable(Connection connection, String clientHighWaterMarkTableName) throws SQLException { executeSQL( "DROP TABLE IF EXISTS " + clientHighWaterMarkTableName, connection, true // ignore exception ); executeSQL( "CREATE TABLE " + clientHighWaterMarkTableName + " (" + "PARTITION_ID INTEGER NOT NULL," + "HIGH_WATER_MARK BIGINT NOT NULL," + "PRIMARY KEY (PARTITION_ID)" + ")", connection, false ); }
Example #28
Source File: WSQueryEndpoint.java From ksql-fork-with-deep-learning-function with Apache License 2.0 | 4 votes |
@SuppressFBWarnings("NP_NONNULL_PARAM_VIOLATION") private static String getLast(String name, Map<String, List<String>> parameters) { return Iterables.getLast(parameters.get(name), null); }
Example #29
Source File: AbstractGerritSCMSource.java From gerrit-code-review-plugin with Apache License 2.0 | 4 votes |
@SuppressFBWarnings(value = "NP_BOOLEAN_RETURN_NULL", justification = "Overridden") public Boolean getInsecureHttps() { return null; }
Example #30
Source File: PlainSaslCallbackHandler.java From ballerina-message-broker with Apache License 2.0 | 4 votes |
@SuppressFBWarnings("EI_EXPOSE_REP2") public void setPassword(char... password) { this.password = password; }