edu.umd.cs.findbugs.annotations.SuppressWarnings Java Examples

The following examples show how to use edu.umd.cs.findbugs.annotations.SuppressWarnings. 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: GMBatchCommandTest.java    From gm4java with Apache License 2.0 6 votes vote down vote up
@Test
public void run_handlesBufferedImageAsInput() throws Exception {
    final String command = "convert";
    sut = new GMBatchCommand(service, command);
    BufferedImage image = ImageIO.read(getClass().getResourceAsStream("/a.png"));
    IMOperation op = new IMOperation();
    op.addImage();                        // input
    op.resize(80, 60);
    op.addImage();                        // output

    sut.run(op, image, TARGET_IMAGE);

    @java.lang.SuppressWarnings("unchecked")
    ArgumentCaptor<List<String>> captor = ArgumentCaptor.forClass((Class<List<String>>) (Class<?>) List.class);
    verify(service).execute(captor.capture());
    assertThat(captor.getValue(),
            equalTo(Arrays.asList(command, captor.getValue().get(1), "-resize", "80x60", TARGET_IMAGE)));
}
 
Example #2
Source File: GMBatchCommandTest.java    From gm4java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("NP_NONNULL_PARAM_VIOLATION")
public void run_works_whenOutputConsumerIsNull() throws Exception {
    // create command
    final String command = "convert";
    sut = new GMBatchCommand(service, command);
    // create the operation, add images and operators/options
    IMOperation op = new IMOperation();
    op.addImage(SOURCE_IMAGE);
    op.resize(800, 600);
    op.addImage(TARGET_IMAGE);
    sut.setOutputConsumer(null);

    // execute the operation
    sut.run(op);

    verify(service).execute(Arrays.asList(command, SOURCE_IMAGE, "-resize", "800x600", TARGET_IMAGE));
}
 
Example #3
Source File: MultiTableSnapshotInputFormat.java    From hbase with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("checkstyle:linelength")
/**
 * Configure conf to read from snapshotScans, with snapshots restored to a subdirectory of
 * restoreDir.
 * Sets:
 * {@link org.apache.hadoop.hbase.mapreduce.MultiTableSnapshotInputFormatImpl#RESTORE_DIRS_KEY},
 * {@link org.apache.hadoop.hbase.mapreduce.MultiTableSnapshotInputFormatImpl#SNAPSHOT_TO_SCANS_KEY}
 *
 * @param conf
 * @param snapshotScans
 * @param restoreDir
 * @throws IOException
 */
public static void setInput(Configuration conf, Map<String, Collection<Scan>> snapshotScans,
    Path restoreDir) throws IOException {
  new MultiTableSnapshotInputFormatImpl().setInput(conf, snapshotScans, restoreDir);
}
 
Example #4
Source File: GMBatchCommandTest.java    From gm4java with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("NP_NONNULL_PARAM_VIOLATION")
public void run_chokes_whenErrorConsumerIsNull() throws Exception {
    // create command
    final String command = "bad";
    sut = new GMBatchCommand(service, command);
    // create the operation, add images and operators/options
    IMOperation op = new IMOperation();
    op.addImage(SOURCE_IMAGE);
    op.resize(800, 600);
    op.addImage(TARGET_IMAGE);
    final String message = "bad command";
    when(service.execute(anyListOf(String.class))).thenThrow(new GMException(message));
    exception.expect(CommandException.class);
    exception.expectMessage(message);
    sut.setErrorConsumer(null);

    // execute the operation
    sut.run(op);
}
 
Example #5
Source File: TempFileWarningLogger.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE")
public boolean checkFiles()
{
    if (log.isDebugEnabled())
    {
        log.debug("Looking for temp files matching " + glob + " in directory " + dir);
    }
    
    try(DirectoryStream<Path> stream = Files.newDirectoryStream(dir, glob))
    {
        for (Path file : stream)
        {
            if (log.isDebugEnabled())
            {
                log.debug("Solr suggester temp file found matching file pattern: " + glob + ", path: " + file);
                log.debug("Removing suggester temp files.");
            }
            return true;
        }
        return false;
    }
    catch (IOException e)
    {
        throw new RuntimeException("Unable to create directory stream", e);
    }
}
 
Example #6
Source File: CompileTest.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
@SuppressWarnings(value = "NP_LOAD_OF_KNOWN_NULL_VALUE")
protected void setUp() throws Exception {
	super.setUp();
	
	StringBuffer tmp = new StringBuffer();
	tmp.append("package org.jetel.userclasses;\n");
	tmp.append("public class test1 {\n");
	tmp.append("\tpublic static Integer addTwo(Integer i, Integer ii) {\n");
	tmp.append("\t\treturn new Integer(i.intValue()+ii.intValue());\n");
	tmp.append("\t}\n");
	tmp.append("}\n");
	src1 = tmp.toString();

	tmp = new StringBuffer();
	tmp.append("public class Main {\n");
	tmp.append("public void method(Object s) {} \n");
	tmp.append("public void method(Long l) {} \n");
	tmp.append("public static void main(String[] args) {\n");
	tmp.append("	Main m = new Main();\n");
	tmp.append("	m.method(1==1 ? \"a\" : new Long(1)); \n");
	tmp.append("}\n");
	tmp.append("}\n");
	src2 = tmp.toString();
}
 
Example #7
Source File: AbstractGMConnectionTest.java    From gm4java with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("NP_NONNULL_PARAM_VIOLATION")
public void executeByList_chokes_onNullCommand() throws Exception {
    exception.expect(NullPointerException.class);
    exception.expectMessage("command");
    exception.expectMessage("null");
    sut().execute((List<String>) null);
}
 
Example #8
Source File: SimpleGMServiceTest.java    From gm4java with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("NP_NONNULL_PARAM_VIOLATION")
public void setGMPath_chokes_onNullPath() {
    exception.expect(NullPointerException.class);
    exception.expectMessage("gmPath");

    sut.setGMPath(null);
}
 
Example #9
Source File: PooledGMConnectionTest.java    From gm4java with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("NP_NONNULL_PARAM_VIOLATION")
public void constructor_chokes_onNullPath() throws Exception {
    exception.expect(NullPointerException.class);
    exception.expectMessage("pool");
    new PooledGMConnection(null);
}
 
Example #10
Source File: InstrumentedExtractorBase.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * Subclasses should implement this or {@link #readRecordImpl(Object)}
 * instead of {@link org.apache.gobblin.source.extractor.Extractor#readRecord}
 */
@SuppressWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE",
    justification = "Findbugs believes readRecord(null) is non-null. This is not true.")
protected RecordEnvelope<D> readRecordEnvelopeImpl() throws DataRecordException, IOException {
  D record = readRecordImpl(null);
  return  record == null ? null : new RecordEnvelope<>(record);
}
 
Example #11
Source File: Extractor.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * Read an {@link RecordEnvelope}. By default, just wrap {@link #readRecord(Object)} in a {@link RecordEnvelope}.
 */
@SuppressWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE",
    justification = "Findbugs believes readRecord(null) is non-null. This is not true.")
default RecordEnvelope<D> readRecordEnvelope() throws DataRecordException, IOException {
  D record = readRecord(null);
  return record == null ? null : new RecordEnvelope<>(record);
}
 
Example #12
Source File: BasicGMConnectionTest.java    From gm4java with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("NP_NONNULL_PARAM_VIOLATION")
public void constructor_chokes_onNullPath() throws Exception {
    exception.expect(NullPointerException.class);
    exception.expectMessage("process");
    new BasicGMConnection(null);
}
 
Example #13
Source File: PooledGMServiceTest.java    From gm4java with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("NP_NONNULL_PARAM_VIOLATION")
public void constructor_chokes_onNullConfig() throws Exception {
    exception.expect(NullPointerException.class);
    exception.expectMessage("config");
    config = null;

    new PooledGMService(config);
}
 
Example #14
Source File: AbstractGMConnectionTest.java    From gm4java with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("NP_NONNULL_PARAM_VIOLATION")
public void execute_chokes_onNullCommand() throws Exception {
    exception.expect(NullPointerException.class);
    exception.expectMessage("command");
    exception.expectMessage("null");
    sut().execute((String) null);
}
 
Example #15
Source File: GMConnectionPoolTest.java    From gm4java with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("NP_NONNULL_PARAM_VIOLATION")
public void constructor_chokes_onNullConfig() throws Exception {
    exception.expect(NullPointerException.class);
    exception.expectMessage("config");

    new GMConnectionPool(null);
}
 
Example #16
Source File: GMConnectionPoolTest.java    From gm4java with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("NP_NONNULL_PARAM_VIOLATION")
public void setGMPath_chokes_onNullPath() throws Exception {
    exception.expect(NullPointerException.class);
    exception.expectMessage("gmPath");

    sut.setGMPath(null);
}
 
Example #17
Source File: TransformLangExecutorRuntimeException.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SuppressWarnings(value="EI2")
public TransformLangExecutorRuntimeException(SimpleNode node,Object[] arguments,String message,Throwable cause){
	//that is the way how to ensure that the given message is printed out to the graph log as follow-up exception, on separate line - better chain of messages layout
    super(new JetelRuntimeException(message, cause)); 
    this.nodeInError=node;
    this.arguments=arguments;
}
 
Example #18
Source File: BadlyOverriddenAdapterTest.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
public BadlyOverriddenAdapterTest() {
    addWindowListener(new WindowAdapter() {
        @SuppressWarnings("DM_EXIT")
        @ExpectWarning("BOA")
        public void windowClosing() {
            dispose();
            System.exit(0);
        }
    });

    Container cp = getContentPane();
    cp.add(new JButton("Click Me"));
}
 
Example #19
Source File: TempFileWarningLogger.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE")
public void removeFiles()
{
    try(DirectoryStream<Path> stream = Files.newDirectoryStream(dir, glob))
    {
        for (Path file : stream)
        {
            file.toFile().delete();
        }
    }
    catch (IOException e) 
    {
        log.debug("Unable to delete temp file", e);
    }
}
 
Example #20
Source File: ConfigStoreBackedValueInspector.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings
private Config getResolvedConfigRecursive(ConfigKeyPath configKey, Set<String> alreadyLoadedPaths) {
  return getResolvedConfigRecursive(configKey, alreadyLoadedPaths, Optional.<Config>absent());
}
 
Example #21
Source File: AsyncHttpJoinConverter.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
public AsyncHttpJoinConverterContext(AsyncHttpJoinConverter converter, SO outputSchema, DI input, Request<RQ> request) {
  this.future = new CompletableFuture();
  this.converter = converter;
  this.callback = new Callback<RP>() {
    @Override
    public void onSuccess(RP result) {
      try {
        ResponseStatus status = AsyncHttpJoinConverterContext.this.converter.responseHandler.handleResponse(request, result);
        switch (status.getType()) {
          case OK:
            AsyncHttpJoinConverterContext.this.onSuccess(request.getRawRequest(), status, outputSchema, input);
            break;
          case CLIENT_ERROR:
            log.error ("Http converter client error with request {}", request.getRawRequest());
            AsyncHttpJoinConverterContext.this.onSuccess(request.getRawRequest(), status, outputSchema, input);
            break;
          case SERVER_ERROR:
            // Server side error. Retry
            log.error ("Http converter server error with request {}", request.getRawRequest());
            throw new DataConversionException(request.getRawRequest() + " send failed due to server error");
          default:
            throw new DataConversionException(request.getRawRequest() + " Should not reach here");
        }
      } catch (Exception e) {
        log.error ("Http converter exception {} with request {}", e.toString(), request.getRawRequest());
        AsyncHttpJoinConverterContext.this.future.completeExceptionally(e);
      }
    }

    @SuppressWarnings(value = "NP_NONNULL_PARAM_VIOLATION",
        justification = "CompletableFuture will replace null value with NIL")
    @Override
    public void onFailure(Throwable throwable) {
      String errorMsg = ExceptionUtils.getMessage(throwable);
      log.error ("Http converter on failure with request {} and throwable {}", request.getRawRequest(), errorMsg);

      if (skipFailedRecord) {
        AsyncHttpJoinConverterContext.this.future.complete( null);
      } else {
        AsyncHttpJoinConverterContext.this.future.completeExceptionally(throwable);
      }
    }
  };
}
 
Example #22
Source File: DBFDataFormatterTest.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
@SuppressWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
protected void tearDown() throws Exception {
	Defaults.DEFAULT_INTERNAL_IO_BUFFER_SIZE = oldBufferSize;
}
 
Example #23
Source File: DataParserTest.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
@SuppressWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
protected void tearDown() throws Exception {
	super.tearDown();
	Defaults.DEFAULT_INTERNAL_IO_BUFFER_SIZE = oldBufferSize;
}
 
Example #24
Source File: DataParserTest.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
public void testEvenBufferSize() throws Exception {
	Defaults.DEFAULT_INTERNAL_IO_BUFFER_SIZE = 16;
	testParsers();
}
 
Example #25
Source File: DataParserTest.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
public void testOddBufferSize() throws Exception {
	Defaults.DEFAULT_INTERNAL_IO_BUFFER_SIZE = 15;
	testParsers();
}
 
Example #26
Source File: TransformLangExecutorRuntimeException.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings(value="EI")
public Object[] getArguments(){
	return arguments;
}
 
Example #27
Source File: TextTableFormatterProvider.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings(value="EI2")
public void setMask(String[] mask) {
	this.mask = mask;
}
 
Example #28
Source File: Bug1927503.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void setArr2(@SuppressWarnings("EI2") byte[] newArr) {
    arr2 = newArr;
}
 
Example #29
Source File: Bug1927503.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Bug1927503(@SuppressWarnings("EI2") byte[] newArr) {
    arr = newArr;
}
 
Example #30
Source File: DatasetReader.java    From kite with Apache License 2.0 2 votes vote down vote up
/**
 * <p>
 * Fetch the next entity from the reader.
 * </p>
 * <p>
 * Calling this method when no additional data exists is illegal; you should
 * use {@link #hasNext()} to test if a call to {@code read()} will succeed.
 * Implementations of this method can block.
 * </p>
 *
 * @return An entity of type {@code E}.
 * @throws DatasetOperationException
 *            If the operation did not succeed.
 * @throws DatasetIOException
 *            To wrap an internal {@link java.io.IOException}
 * @throws NoSuchElementException
 *
 * @since 0.7.0
 */
@SuppressWarnings(value="IT_NO_SUCH_ELEMENT",
    justification="Implementations should throw NoSuchElementException")
@Override
E next();