本文整理汇总了Java中edu.umd.cs.findbugs.annotations.SuppressWarnings类的典型用法代码示例。如果您正苦于以下问题:Java SuppressWarnings类的具体用法?Java SuppressWarnings怎么用?Java SuppressWarnings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SuppressWarnings类属于edu.umd.cs.findbugs.annotations包,在下文中一共展示了SuppressWarnings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
/**
* Initializes this collector by creating a {@link StatArchiveHandler} and registering it as a
* handler.
*
* @param config defines the configuration for the StatArchiveHandler
* @param nanosTimeStamp the nanos time stamp to initialize stat archiver with
* @param rollingFileHandler provides file rolling behavior
*/
@SuppressWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD",
justification = "There is never more than one SampleCollector instance.")
public void initialize(final StatArchiveHandlerConfig config, final long nanosTimeStamp,
final RollingFileHandler rollingFileHandler) {
synchronized (SampleCollector.class) {
instance = this;
synchronized (this.sampleHandlers) {
StatArchiveHandler newStatArchiveHandler =
new StatArchiveHandler(config, this, rollingFileHandler);
this.statArchiveHandler = newStatArchiveHandler;
addSampleHandler(newStatArchiveHandler);
newStatArchiveHandler.initialize(nanosTimeStamp);
}
}
}
示例2: fileToString
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
@SuppressWarnings(value = "DM_DEFAULT_ENCODING")
protected String fileToString(File f) {
StringBuffer sb = new StringBuffer();
try (FileReader fileRead = new FileReader(f); BufferedReader reader = new BufferedReader(fileRead);) {
String line;
while (true) {
line = reader.readLine();
if (line == null)
break;
sb.append(line);
sb.append("\n");
}
} catch (Throwable e) {
}
return sb.toString();
}
示例3: fileToString
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
@SuppressWarnings(value = "DM_DEFAULT_ENCODING")
protected String fileToString(File f) {
StringBuffer sb = new StringBuffer();
try (FileReader fileRead = new FileReader(f);
BufferedReader reader = new BufferedReader(fileRead);) {
String line;
while (true) {
line = reader.readLine();
if (line == null)
break;
sb.append(line);
sb.append("\n");
}
} catch (Throwable e) {
}
return sb.toString();
}
示例4: getIP
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
@SuppressWarnings(value = "DM_DEFAULT_ENCODING", justification = "There are no other changes when the content encoding is not present in the HTTP response")
public String getIP() throws IpRetrievalException {
try {
URL url = new URL("https://icanhazip.com");
URLConnection conn = url.openConnection();
String encoding = conn.getContentEncoding();
// open the stream and put it into BufferedReader
InputStreamReader isr = encoding == null ? new InputStreamReader(
conn.getInputStream()) : new InputStreamReader(
conn.getInputStream(), encoding);
BufferedReader br = new BufferedReader(isr);
String line = br.readLine();
br.close();
log.info("Public IP: " + line);
return line;
} catch (Exception e) {
log.error("Cannot get IP from " + "https://icanhazip.com");
IpRetrievalException ex = new IpRetrievalException(
"Cannot get IP from " + "https://icanhazip.com", e);
ex.setProviderName(providerName());
throw ex;
}
}
示例5: getIP
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
@SuppressWarnings(value="DM_DEFAULT_ENCODING",justification="There are no other changes when the content encoding is not present in the HTTP response")
public String getIP() throws IpRetrievalException{
try{
URL url = new URL("https://icanhazip.com");
URLConnection conn = url.openConnection();
String encoding = conn.getContentEncoding();
// open the stream and put it into BufferedReader
InputStreamReader isr = encoding == null ? new InputStreamReader(conn.getInputStream()) : new InputStreamReader(conn.getInputStream(),encoding);
BufferedReader br = new BufferedReader(isr);
String line = br.readLine();
br.close();
log.info("Public IP: "+line);
return line;
}catch(Exception e){
log.error("Cannot get IP from "+"https://icanhazip.com");
IpRetrievalException ex = new IpRetrievalException("Cannot get IP from "+"https://icanhazip.com", e);
ex.setProviderName(providerName());
throw ex;
}
}
示例6: testStream
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
/**
* Test dataset stream
*/
@java.lang.SuppressWarnings("unchecked")
@TestWith({"testMetaDataCsvBatch", "testMetaDataXmlBatch"})
public void testStream(TestMetaData testMetaData) throws IOException, EventDeliveryException, InterruptedException {
assertEquals(((Integer) testMetaData.getParameters()[2].get(KEY_FLUME_PROCESS_FILE_COUNT)).intValue(),
flumeServer.crankPipeline(FLUME_SUBSTITUTIONS, FLUME_CONFIG_FILE, testMetaData.getParameters()[0], testMetaData.getParameters()[1],
FLUME_AGENT_NAME, (String) testMetaData.getParameters()[2].get(KEY_FLUME_SOURCE_NAME),
(String) testMetaData.getParameters()[2].get(KEY_FLUME_SINK_NAME), new com.cloudera.framework.example.one.stream.Stream(),
new HDFSEventSink(), (String) testMetaData.getParameters()[2].get(KEY_FLUME_OUTPUT_DIR),
(Integer) testMetaData.getParameters()[2].get(KEY_FLUME_PROCESS_ITERATIONS), iterations -> 1));
Driver driverStage = new Stage(dfsServer.getConf());
assertEquals(SUCCESS, driverStage.runner(
dfsServer.getPath(DIR_ABS_MYDS_RAW_CANONICAL).toString(), dfsServer.getPath(DIR_ABS_MYDS_STAGED).toString()));
assertCounterEquals(testMetaData, driverStage.getCounters());
Driver driverPartition = new Partition(dfsServer.getConf());
assertEquals(SUCCESS, driverPartition.runner(dfsServer.getPath(DIR_ABS_MYDS_STAGED_CANONICAL).toString(),
dfsServer.getPath(DIR_ABS_MYDS_PARTITIONED).toString()));
assertCounterEquals(testMetaData, 1, driverPartition.getCounters());
Driver driverProcess = new Cleanse(dfsServer.getConf());
assertEquals(SUCCESS, driverProcess.runner(dfsServer.getPath(DIR_ABS_MYDS_PARTITIONED_CANONICAL).toString(), dfsServer.getPath
(DIR_ABS_MYDS_CLEANSED).toString()));
assertCounterEquals(testMetaData, 2, driverProcess.getCounters());
}
示例7: logError
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
@SuppressWarnings("DM_EXIT")
public void logError(String message, Throwable e) {
if (e instanceof MissingClassException) {
MissingClassException missingClassEx = (MissingClassException) e;
ClassNotFoundException cnfe = missingClassEx.getClassNotFoundException();
reportMissingClass(cnfe);
// Don't report dataflow analysis exceptions due to missing classes.
// Too much noise.
return;
}
if (e instanceof MethodUnprofitableException) {
// TODO: log this
return;
}
System.err.println("Error: " + message);
e.printStackTrace();
System.exit(1);
}
示例8: call
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
@edu.umd.cs.findbugs.annotations.SuppressWarnings(
value = {"NP_LOAD_OF_KNOWN_NULL_VALUE"},
justification = "Findbugs mis-diagnosing closeQuietly's built-in null check"
)
public String call() throws RuntimeException {
InputStream is = null;
try {
is = hudson.remoting.Channel.class.getResourceAsStream("/jenkins/remoting/jenkins-version.properties");
if (is == null) {
return "N/A";
}
Properties properties = new Properties();
try {
properties.load(is);
return properties.getProperty("version", "N/A");
} catch (IOException e) {
return "N/A";
}
} finally {
IOUtils.closeQuietly(is);
}
}
示例9: run_chokes_whenErrorConsumerIsNull
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
@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);
}
示例10: run_works_whenOutputConsumerIsNull
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
@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));
}
示例11: run_handlesBufferedImageAsInput
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
@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)));
}
示例12: pressQEnterToContinue
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
@edu.umd.cs.findbugs.annotations.SuppressWarnings(
value = "DM_DEFAULT_ENCODING",
justification = "Just reading key-input, encoding does not matter here")
static void pressQEnterToContinue() {
try {
// sleep a while to have the log output at the end
Thread.sleep(1000);
} catch (InterruptedException e) {
// nothing to do
}
LOG.info("\n\n\n************************************************\n Please press \"q + <Enter>\" to quit application\n************************************************\n\n");
Scanner input = new Scanner(System.in);
Pattern pattern = Pattern.compile("q");
// wait until the user types q to quit
input.next(pattern);
input.close();
}
示例13: StreamResourceTracker
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
/**
* Constructor.
*
* @param streamFactoryList array of StreamFactory objects which determine
* where streams are created
* @param lookupFailureCallback used when class hierarchy lookups fail
*/
@SuppressWarnings("EI2")
public StreamResourceTracker(StreamFactory[] streamFactoryList,
RepositoryLookupFailureCallback lookupFailureCallback) {
this.streamFactoryList = streamFactoryList;
this.lookupFailureCallback = lookupFailureCallback;
this.streamOpenLocationMap = new HashMap<Location, Stream>();
this.uninterestingStreamEscapeSet = new HashSet<Stream>();
this.streamEscapeSet = new TreeSet<StreamEscape>();
this.streamEquivalenceMap = new HashMap<Stream, StreamEquivalenceClass>();
}
示例14: BetterTypeAnalysis
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
@SuppressWarnings("EI2")
public BetterTypeAnalysis(MethodGen methodGen, String[] parameterSignatureList,
CFG cfg, DepthFirstSearch dfs,
TypeRepository typeRepository, TypeMerger typeMerger,
RepositoryLookupFailureCallback lookupFailureCallback) {
super(dfs);
this.methodGen = methodGen;
this.parameterSignatureList = parameterSignatureList;
// this.cfg = cfg;
this.typeRepository = typeRepository;
this.typeMerger = typeMerger;
this.lookupFailureCallback = lookupFailureCallback;
}
示例15: finish
import edu.umd.cs.findbugs.annotations.SuppressWarnings; //导入依赖的package包/类
/**
* Mark the object as complete.
*
* @param missingClassList the list of names of missing classes
*/
@SuppressWarnings("EI2")
public void finish(String[] missingClassList) {
if (missingClassList.length > 0)
this.missingClassList = missingClassList;
supertypeListInBFSOrder.trimToSize();
}