repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.jms.2.0/src/com/ibm/ws/sib/api/jmsra/impl/JmsJcaConnectionRequestInfo.java | JmsJcaConnectionRequestInfo.setSICoreConnection | void setSICoreConnection(final SICoreConnection connection) {
if (TRACE.isEntryEnabled()) {
SibTr.entry(this, TRACE, "setSICoreConnection", connection);
}
_coreConnection = connection;
if (TRACE.isEntryEnabled()) {
SibTr.exit(this, TRACE, "setSICoreConnection"); //412795
}
} | java | void setSICoreConnection(final SICoreConnection connection) {
if (TRACE.isEntryEnabled()) {
SibTr.entry(this, TRACE, "setSICoreConnection", connection);
}
_coreConnection = connection;
if (TRACE.isEntryEnabled()) {
SibTr.exit(this, TRACE, "setSICoreConnection"); //412795
}
} | [
"void",
"setSICoreConnection",
"(",
"final",
"SICoreConnection",
"connection",
")",
"{",
"if",
"(",
"TRACE",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"SibTr",
".",
"entry",
"(",
"this",
",",
"TRACE",
",",
"\"setSICoreConnection\"",
",",
"connection",
")",
";",
"}",
"_coreConnection",
"=",
"connection",
";",
"if",
"(",
"TRACE",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"SibTr",
".",
"exit",
"(",
"this",
",",
"TRACE",
",",
"\"setSICoreConnection\"",
")",
";",
"//412795",
"}",
"}"
] | Sets the connection that was created as a result of this request.
@param connection
the connection | [
"Sets",
"the",
"connection",
"that",
"was",
"created",
"as",
"a",
"result",
"of",
"this",
"request",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.jms.2.0/src/com/ibm/ws/sib/api/jmsra/impl/JmsJcaConnectionRequestInfo.java#L191-L203 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/cache/internal/ZipFileHandleImpl.java | ZipFileHandleImpl.open | @Override
@Trivial
public ZipFile open() throws IOException {
String methodName = "open";
synchronized( zipFileLock ) {
if ( zipFile == null ) {
debug(methodName, "Opening");
if ( zipFileReaper == null ) {
zipFile = ZipFileUtils.openZipFile(file); // throws IOException
} else {
zipFile = zipFileReaper.open(path);
}
}
openCount++;
debug(methodName, "Opened");
return zipFile;
}
} | java | @Override
@Trivial
public ZipFile open() throws IOException {
String methodName = "open";
synchronized( zipFileLock ) {
if ( zipFile == null ) {
debug(methodName, "Opening");
if ( zipFileReaper == null ) {
zipFile = ZipFileUtils.openZipFile(file); // throws IOException
} else {
zipFile = zipFileReaper.open(path);
}
}
openCount++;
debug(methodName, "Opened");
return zipFile;
}
} | [
"@",
"Override",
"@",
"Trivial",
"public",
"ZipFile",
"open",
"(",
")",
"throws",
"IOException",
"{",
"String",
"methodName",
"=",
"\"open\"",
";",
"synchronized",
"(",
"zipFileLock",
")",
"{",
"if",
"(",
"zipFile",
"==",
"null",
")",
"{",
"debug",
"(",
"methodName",
",",
"\"Opening\"",
")",
";",
"if",
"(",
"zipFileReaper",
"==",
"null",
")",
"{",
"zipFile",
"=",
"ZipFileUtils",
".",
"openZipFile",
"(",
"file",
")",
";",
"// throws IOException",
"}",
"else",
"{",
"zipFile",
"=",
"zipFileReaper",
".",
"open",
"(",
"path",
")",
";",
"}",
"}",
"openCount",
"++",
";",
"debug",
"(",
"methodName",
",",
"\"Opened\"",
")",
";",
"return",
"zipFile",
";",
"}",
"}"
] | Open the zip file. Create and assign the zip file if this is the first
open. Increase the open count by one.
If this is the first open and the zip file could not be created, the
open count is not increased.
@return The zip file. | [
"Open",
"the",
"zip",
"file",
".",
"Create",
"and",
"assign",
"the",
"zip",
"file",
"if",
"this",
"is",
"the",
"first",
"open",
".",
"Increase",
"the",
"open",
"count",
"by",
"one",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/cache/internal/ZipFileHandleImpl.java#L142-L162 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/cache/internal/ZipFileHandleImpl.java | ZipFileHandleImpl.getInputStream | @Override
@Trivial
public InputStream getInputStream(ZipFile useZipFile, ZipEntry zipEntry) throws IOException {
String methodName = "getInputStream";
String entryName = zipEntry.getName();
if ( zipEntry.isDirectory() ) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled() ) {
debug(methodName, "Entry [ " + entryName + " ] [ null ] (Not using cache: Directory entry)");
}
return null;
}
long entrySize = zipEntry.getSize();
if ( entrySize == 0 ) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled() ) {
debug(methodName, "Entry [ " + entryName + " ] [ empty stream ] (Not using cache: Empty entry)");
}
return EMPTY_STREAM;
}
boolean doNotCache;
String doNotCacheReason;
if ( zipEntries == null ) { // No entry cache.
doNotCache = true;
doNotCacheReason = "Do not cache: Entry cache disabled";
} else if ( entrySize > ZipCachingProperties.ZIP_CACHE_ENTRY_LIMIT) { // Too big for the cache
doNotCache = true;
doNotCacheReason = "Do not cache: Too big";
} else if ( entryName.equals("META-INF/MANIFEST.MF") ) {
doNotCache = false;
doNotCacheReason = "Cache META-INF/MANIFEST.MF";
} else if ( entryName.endsWith(".class") ) {
doNotCache = false;
doNotCacheReason = "Cache .class resources";
} else {
doNotCache = true;
doNotCacheReason = "Do not cache: Not manifest or class resource";
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled() ) {
debug(methodName, "Entry [ " + entryName + " ] [ non-null ] [ " + doNotCacheReason + " ]");
}
if ( doNotCache ) {
return useZipFile.getInputStream(zipEntry); // throws IOException
}
// The addition of ":::" *seems* to allow for non-unique cache keys. Duplicate
// keys *are not* possible because the CRC and last-modified values are numeric.
// Duplicate keys would be possible of the CRC or last-modified values, when
// converted to strings, could contain ":::" character sequences.
String entryCacheKey =
entryName +
":::" + Long.toString( zipEntry.getCrc() ) +
":::" + Long.toString( getLastModified() );
// Note that only the individual gets and puts are protected.
//
// That means that simultaneous get misses are possible, which
// will result in double reads and double puts.
//
// That is unfortunate, but is harmless.
//
// The simultaneous puts are allowed because they should be very
// rare.
//
// They are allowed because blocking entry gets while waiting for
// reads could create large delays.
byte[] entryBytes;
synchronized( zipEntriesLock ) {
entryBytes = zipEntries.get(entryCacheKey);
}
if ( entryBytes == null ) {
InputStream inputStream = useZipFile.getInputStream(zipEntry); // throws IOException
try {
entryBytes = read(inputStream, (int) entrySize, entryName); // throws IOException
} finally {
inputStream.close(); // throws IOException
}
synchronized( zipEntriesLock ) {
zipEntries.put(entryCacheKey, entryBytes);
}
}
return new ByteArrayInputStream(entryBytes);
} | java | @Override
@Trivial
public InputStream getInputStream(ZipFile useZipFile, ZipEntry zipEntry) throws IOException {
String methodName = "getInputStream";
String entryName = zipEntry.getName();
if ( zipEntry.isDirectory() ) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled() ) {
debug(methodName, "Entry [ " + entryName + " ] [ null ] (Not using cache: Directory entry)");
}
return null;
}
long entrySize = zipEntry.getSize();
if ( entrySize == 0 ) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled() ) {
debug(methodName, "Entry [ " + entryName + " ] [ empty stream ] (Not using cache: Empty entry)");
}
return EMPTY_STREAM;
}
boolean doNotCache;
String doNotCacheReason;
if ( zipEntries == null ) { // No entry cache.
doNotCache = true;
doNotCacheReason = "Do not cache: Entry cache disabled";
} else if ( entrySize > ZipCachingProperties.ZIP_CACHE_ENTRY_LIMIT) { // Too big for the cache
doNotCache = true;
doNotCacheReason = "Do not cache: Too big";
} else if ( entryName.equals("META-INF/MANIFEST.MF") ) {
doNotCache = false;
doNotCacheReason = "Cache META-INF/MANIFEST.MF";
} else if ( entryName.endsWith(".class") ) {
doNotCache = false;
doNotCacheReason = "Cache .class resources";
} else {
doNotCache = true;
doNotCacheReason = "Do not cache: Not manifest or class resource";
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled() ) {
debug(methodName, "Entry [ " + entryName + " ] [ non-null ] [ " + doNotCacheReason + " ]");
}
if ( doNotCache ) {
return useZipFile.getInputStream(zipEntry); // throws IOException
}
// The addition of ":::" *seems* to allow for non-unique cache keys. Duplicate
// keys *are not* possible because the CRC and last-modified values are numeric.
// Duplicate keys would be possible of the CRC or last-modified values, when
// converted to strings, could contain ":::" character sequences.
String entryCacheKey =
entryName +
":::" + Long.toString( zipEntry.getCrc() ) +
":::" + Long.toString( getLastModified() );
// Note that only the individual gets and puts are protected.
//
// That means that simultaneous get misses are possible, which
// will result in double reads and double puts.
//
// That is unfortunate, but is harmless.
//
// The simultaneous puts are allowed because they should be very
// rare.
//
// They are allowed because blocking entry gets while waiting for
// reads could create large delays.
byte[] entryBytes;
synchronized( zipEntriesLock ) {
entryBytes = zipEntries.get(entryCacheKey);
}
if ( entryBytes == null ) {
InputStream inputStream = useZipFile.getInputStream(zipEntry); // throws IOException
try {
entryBytes = read(inputStream, (int) entrySize, entryName); // throws IOException
} finally {
inputStream.close(); // throws IOException
}
synchronized( zipEntriesLock ) {
zipEntries.put(entryCacheKey, entryBytes);
}
}
return new ByteArrayInputStream(entryBytes);
} | [
"@",
"Override",
"@",
"Trivial",
"public",
"InputStream",
"getInputStream",
"(",
"ZipFile",
"useZipFile",
",",
"ZipEntry",
"zipEntry",
")",
"throws",
"IOException",
"{",
"String",
"methodName",
"=",
"\"getInputStream\"",
";",
"String",
"entryName",
"=",
"zipEntry",
".",
"getName",
"(",
")",
";",
"if",
"(",
"zipEntry",
".",
"isDirectory",
"(",
")",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"debug",
"(",
"methodName",
",",
"\"Entry [ \"",
"+",
"entryName",
"+",
"\" ] [ null ] (Not using cache: Directory entry)\"",
")",
";",
"}",
"return",
"null",
";",
"}",
"long",
"entrySize",
"=",
"zipEntry",
".",
"getSize",
"(",
")",
";",
"if",
"(",
"entrySize",
"==",
"0",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"debug",
"(",
"methodName",
",",
"\"Entry [ \"",
"+",
"entryName",
"+",
"\" ] [ empty stream ] (Not using cache: Empty entry)\"",
")",
";",
"}",
"return",
"EMPTY_STREAM",
";",
"}",
"boolean",
"doNotCache",
";",
"String",
"doNotCacheReason",
";",
"if",
"(",
"zipEntries",
"==",
"null",
")",
"{",
"// No entry cache.",
"doNotCache",
"=",
"true",
";",
"doNotCacheReason",
"=",
"\"Do not cache: Entry cache disabled\"",
";",
"}",
"else",
"if",
"(",
"entrySize",
">",
"ZipCachingProperties",
".",
"ZIP_CACHE_ENTRY_LIMIT",
")",
"{",
"// Too big for the cache",
"doNotCache",
"=",
"true",
";",
"doNotCacheReason",
"=",
"\"Do not cache: Too big\"",
";",
"}",
"else",
"if",
"(",
"entryName",
".",
"equals",
"(",
"\"META-INF/MANIFEST.MF\"",
")",
")",
"{",
"doNotCache",
"=",
"false",
";",
"doNotCacheReason",
"=",
"\"Cache META-INF/MANIFEST.MF\"",
";",
"}",
"else",
"if",
"(",
"entryName",
".",
"endsWith",
"(",
"\".class\"",
")",
")",
"{",
"doNotCache",
"=",
"false",
";",
"doNotCacheReason",
"=",
"\"Cache .class resources\"",
";",
"}",
"else",
"{",
"doNotCache",
"=",
"true",
";",
"doNotCacheReason",
"=",
"\"Do not cache: Not manifest or class resource\"",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"debug",
"(",
"methodName",
",",
"\"Entry [ \"",
"+",
"entryName",
"+",
"\" ] [ non-null ] [ \"",
"+",
"doNotCacheReason",
"+",
"\" ]\"",
")",
";",
"}",
"if",
"(",
"doNotCache",
")",
"{",
"return",
"useZipFile",
".",
"getInputStream",
"(",
"zipEntry",
")",
";",
"// throws IOException",
"}",
"// The addition of \":::\" *seems* to allow for non-unique cache keys. Duplicate",
"// keys *are not* possible because the CRC and last-modified values are numeric.",
"// Duplicate keys would be possible of the CRC or last-modified values, when",
"// converted to strings, could contain \":::\" character sequences.",
"String",
"entryCacheKey",
"=",
"entryName",
"+",
"\":::\"",
"+",
"Long",
".",
"toString",
"(",
"zipEntry",
".",
"getCrc",
"(",
")",
")",
"+",
"\":::\"",
"+",
"Long",
".",
"toString",
"(",
"getLastModified",
"(",
")",
")",
";",
"// Note that only the individual gets and puts are protected.",
"//",
"// That means that simultaneous get misses are possible, which",
"// will result in double reads and double puts.",
"//",
"// That is unfortunate, but is harmless.",
"//",
"// The simultaneous puts are allowed because they should be very",
"// rare.",
"//",
"// They are allowed because blocking entry gets while waiting for",
"// reads could create large delays.",
"byte",
"[",
"]",
"entryBytes",
";",
"synchronized",
"(",
"zipEntriesLock",
")",
"{",
"entryBytes",
"=",
"zipEntries",
".",
"get",
"(",
"entryCacheKey",
")",
";",
"}",
"if",
"(",
"entryBytes",
"==",
"null",
")",
"{",
"InputStream",
"inputStream",
"=",
"useZipFile",
".",
"getInputStream",
"(",
"zipEntry",
")",
";",
"// throws IOException",
"try",
"{",
"entryBytes",
"=",
"read",
"(",
"inputStream",
",",
"(",
"int",
")",
"entrySize",
",",
"entryName",
")",
";",
"// throws IOException",
"}",
"finally",
"{",
"inputStream",
".",
"close",
"(",
")",
";",
"// throws IOException",
"}",
"synchronized",
"(",
"zipEntriesLock",
")",
"{",
"zipEntries",
".",
"put",
"(",
"entryCacheKey",
",",
"entryBytes",
")",
";",
"}",
"}",
"return",
"new",
"ByteArrayInputStream",
"(",
"entryBytes",
")",
";",
"}"
] | Answer an input stream for an entry of a zip file. When the entry is a
class entry which has 8K or fewer bytes, read all of the entry bytes immediately
and cache the bytes in this handle. Subsequent input stream requests which
locate cached bytes will answer a stream on those bytes.
@param useZipFile The zip file for which to answer an input stream
@param zipEntry The zip entry for which to answer the input stream.
@return An input stream on the bytes of the entry. Null for an directory
type entry, or an entry which has zero bytes.
@throws IOException Thrown if the entry bytes could not be read. | [
"Answer",
"an",
"input",
"stream",
"for",
"an",
"entry",
"of",
"a",
"zip",
"file",
".",
"When",
"the",
"entry",
"is",
"a",
"class",
"entry",
"which",
"has",
"8K",
"or",
"fewer",
"bytes",
"read",
"all",
"of",
"the",
"entry",
"bytes",
"immediately",
"and",
"cache",
"the",
"bytes",
"in",
"this",
"handle",
".",
"Subsequent",
"input",
"stream",
"requests",
"which",
"locate",
"cached",
"bytes",
"will",
"answer",
"a",
"stream",
"on",
"those",
"bytes",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/cache/internal/ZipFileHandleImpl.java#L276-L365 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/cache/internal/ZipFileHandleImpl.java | ZipFileHandleImpl.read | @Trivial
private static byte[] read(InputStream inputStream, int expectedRead, String name) throws IOException {
byte[] bytes = new byte[expectedRead];
int remainingRead = expectedRead;
int totalRead = 0;
while ( remainingRead > 0 ) {
int nextRead = inputStream.read(bytes, totalRead, remainingRead); // throws IOException
if ( nextRead <= 0 ) {
// 'nextRead == 0' should only ever happen if 'remainingRead == 0', which ought
// never be the case here. Treat a '0' return value as an error.
//
// 'nextRead == -1' means the end of input was reached.
throw new IOException(
"Read only [ " + Integer.valueOf(totalRead) + " ]" +
" of expected [ " + Integer.valueOf(expectedRead) + " ] bytes" +
" from [ " + name + " ]");
} else {
remainingRead -= nextRead;
totalRead += nextRead;
}
}
return bytes;
} | java | @Trivial
private static byte[] read(InputStream inputStream, int expectedRead, String name) throws IOException {
byte[] bytes = new byte[expectedRead];
int remainingRead = expectedRead;
int totalRead = 0;
while ( remainingRead > 0 ) {
int nextRead = inputStream.read(bytes, totalRead, remainingRead); // throws IOException
if ( nextRead <= 0 ) {
// 'nextRead == 0' should only ever happen if 'remainingRead == 0', which ought
// never be the case here. Treat a '0' return value as an error.
//
// 'nextRead == -1' means the end of input was reached.
throw new IOException(
"Read only [ " + Integer.valueOf(totalRead) + " ]" +
" of expected [ " + Integer.valueOf(expectedRead) + " ] bytes" +
" from [ " + name + " ]");
} else {
remainingRead -= nextRead;
totalRead += nextRead;
}
}
return bytes;
} | [
"@",
"Trivial",
"private",
"static",
"byte",
"[",
"]",
"read",
"(",
"InputStream",
"inputStream",
",",
"int",
"expectedRead",
",",
"String",
"name",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"expectedRead",
"]",
";",
"int",
"remainingRead",
"=",
"expectedRead",
";",
"int",
"totalRead",
"=",
"0",
";",
"while",
"(",
"remainingRead",
">",
"0",
")",
"{",
"int",
"nextRead",
"=",
"inputStream",
".",
"read",
"(",
"bytes",
",",
"totalRead",
",",
"remainingRead",
")",
";",
"// throws IOException",
"if",
"(",
"nextRead",
"<=",
"0",
")",
"{",
"// 'nextRead == 0' should only ever happen if 'remainingRead == 0', which ought",
"// never be the case here. Treat a '0' return value as an error.",
"//",
"// 'nextRead == -1' means the end of input was reached.",
"throw",
"new",
"IOException",
"(",
"\"Read only [ \"",
"+",
"Integer",
".",
"valueOf",
"(",
"totalRead",
")",
"+",
"\" ]\"",
"+",
"\" of expected [ \"",
"+",
"Integer",
".",
"valueOf",
"(",
"expectedRead",
")",
"+",
"\" ] bytes\"",
"+",
"\" from [ \"",
"+",
"name",
"+",
"\" ]\"",
")",
";",
"}",
"else",
"{",
"remainingRead",
"-=",
"nextRead",
";",
"totalRead",
"+=",
"nextRead",
";",
"}",
"}",
"return",
"bytes",
";",
"}"
] | Read an exact count of bytes from an input stream.
@param inputStream The stream from which to read the bytes.
@param expectedRead The number of bytes which are to be read.
@param name A name associated with the stream.
@return The bytes read from the stream.
@throws IOException Throw if the read failed, including the case where
insufficient bytes were available to be read. | [
"Read",
"an",
"exact",
"count",
"of",
"bytes",
"from",
"an",
"input",
"stream",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/cache/internal/ZipFileHandleImpl.java#L380-L406 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.repository/src/com/ibm/ws/repository/resources/internal/EsaResourceImpl.java | EsaResourceImpl.findVersion | private String findVersion() {
WlpInformation wlp = _asset.getWlpInformation();
if (wlp == null) {
return null;
}
Collection<AppliesToFilterInfo> filterInfo = wlp.getAppliesToFilterInfo();
if (filterInfo == null) {
return null;
}
for (AppliesToFilterInfo filter : filterInfo) {
if (filter.getMinVersion() != null) {
return filter.getMinVersion().getValue();
}
}
return null;
} | java | private String findVersion() {
WlpInformation wlp = _asset.getWlpInformation();
if (wlp == null) {
return null;
}
Collection<AppliesToFilterInfo> filterInfo = wlp.getAppliesToFilterInfo();
if (filterInfo == null) {
return null;
}
for (AppliesToFilterInfo filter : filterInfo) {
if (filter.getMinVersion() != null) {
return filter.getMinVersion().getValue();
}
}
return null;
} | [
"private",
"String",
"findVersion",
"(",
")",
"{",
"WlpInformation",
"wlp",
"=",
"_asset",
".",
"getWlpInformation",
"(",
")",
";",
"if",
"(",
"wlp",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Collection",
"<",
"AppliesToFilterInfo",
">",
"filterInfo",
"=",
"wlp",
".",
"getAppliesToFilterInfo",
"(",
")",
";",
"if",
"(",
"filterInfo",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"AppliesToFilterInfo",
"filter",
":",
"filterInfo",
")",
"{",
"if",
"(",
"filter",
".",
"getMinVersion",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"filter",
".",
"getMinVersion",
"(",
")",
".",
"getValue",
"(",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Uses the filter information to return the first version number
@return the first version number | [
"Uses",
"the",
"filter",
"information",
"to",
"return",
"the",
"first",
"version",
"number"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.repository/src/com/ibm/ws/repository/resources/internal/EsaResourceImpl.java#L121-L138 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.repository/src/com/ibm/ws/repository/resources/internal/EsaResourceImpl.java | EsaResourceImpl.addVersionDisplayString | private void addVersionDisplayString() {
WlpInformation wlp = _asset.getWlpInformation();
JavaSEVersionRequirements reqs = wlp.getJavaSEVersionRequirements();
if (reqs == null) {
return;
}
String minVersion = reqs.getMinVersion();
// Null means no requirements specified which is fine
if (minVersion == null) {
return;
}
String minJava11 = "Java SE 11";
String minJava8 = "Java SE 8, Java SE 11";
String minJava7 = "Java SE 7, Java SE 8, Java SE 11";
String minJava6 = "Java SE 6, Java SE 7, Java SE 8, Java SE 11";
// TODO: Temporary special case for jdbc-4.3 (the first feature to require Java >8)
// Once all builds are upgrade to Java 11+, we can remove this workaround
if ("jdbc-4.3".equals(wlp.getLowerCaseShortName())) {
reqs.setVersionDisplayString(minJava11);
return;
}
// The min version should have been validated when the ESA was constructed
// so checking for the version string should be safe
if (minVersion.equals("1.6.0")) {
reqs.setVersionDisplayString(minJava6);
return;
}
if (minVersion.equals("1.7.0")) {
reqs.setVersionDisplayString(minJava7);
return;
}
if (minVersion.equals("1.8.0")) {
reqs.setVersionDisplayString(minJava8);
return;
}
if (minVersion.startsWith("9.") ||
minVersion.startsWith("10.") ||
minVersion.startsWith("11.")) {
// If a feature requires a min of Java 9/10/11, state Java 11 is required because
// Liberty does not officially support Java 9 or 10
reqs.setVersionDisplayString(minJava11);
return;
}
// The min version string has been generated/validated incorrectly
// Can't recover from this, it is a bug in EsaUploader
throw new AssertionError("Unrecognized java version: " + minVersion);
} | java | private void addVersionDisplayString() {
WlpInformation wlp = _asset.getWlpInformation();
JavaSEVersionRequirements reqs = wlp.getJavaSEVersionRequirements();
if (reqs == null) {
return;
}
String minVersion = reqs.getMinVersion();
// Null means no requirements specified which is fine
if (minVersion == null) {
return;
}
String minJava11 = "Java SE 11";
String minJava8 = "Java SE 8, Java SE 11";
String minJava7 = "Java SE 7, Java SE 8, Java SE 11";
String minJava6 = "Java SE 6, Java SE 7, Java SE 8, Java SE 11";
// TODO: Temporary special case for jdbc-4.3 (the first feature to require Java >8)
// Once all builds are upgrade to Java 11+, we can remove this workaround
if ("jdbc-4.3".equals(wlp.getLowerCaseShortName())) {
reqs.setVersionDisplayString(minJava11);
return;
}
// The min version should have been validated when the ESA was constructed
// so checking for the version string should be safe
if (minVersion.equals("1.6.0")) {
reqs.setVersionDisplayString(minJava6);
return;
}
if (minVersion.equals("1.7.0")) {
reqs.setVersionDisplayString(minJava7);
return;
}
if (minVersion.equals("1.8.0")) {
reqs.setVersionDisplayString(minJava8);
return;
}
if (minVersion.startsWith("9.") ||
minVersion.startsWith("10.") ||
minVersion.startsWith("11.")) {
// If a feature requires a min of Java 9/10/11, state Java 11 is required because
// Liberty does not officially support Java 9 or 10
reqs.setVersionDisplayString(minJava11);
return;
}
// The min version string has been generated/validated incorrectly
// Can't recover from this, it is a bug in EsaUploader
throw new AssertionError("Unrecognized java version: " + minVersion);
} | [
"private",
"void",
"addVersionDisplayString",
"(",
")",
"{",
"WlpInformation",
"wlp",
"=",
"_asset",
".",
"getWlpInformation",
"(",
")",
";",
"JavaSEVersionRequirements",
"reqs",
"=",
"wlp",
".",
"getJavaSEVersionRequirements",
"(",
")",
";",
"if",
"(",
"reqs",
"==",
"null",
")",
"{",
"return",
";",
"}",
"String",
"minVersion",
"=",
"reqs",
".",
"getMinVersion",
"(",
")",
";",
"// Null means no requirements specified which is fine",
"if",
"(",
"minVersion",
"==",
"null",
")",
"{",
"return",
";",
"}",
"String",
"minJava11",
"=",
"\"Java SE 11\"",
";",
"String",
"minJava8",
"=",
"\"Java SE 8, Java SE 11\"",
";",
"String",
"minJava7",
"=",
"\"Java SE 7, Java SE 8, Java SE 11\"",
";",
"String",
"minJava6",
"=",
"\"Java SE 6, Java SE 7, Java SE 8, Java SE 11\"",
";",
"// TODO: Temporary special case for jdbc-4.3 (the first feature to require Java >8)",
"// Once all builds are upgrade to Java 11+, we can remove this workaround",
"if",
"(",
"\"jdbc-4.3\"",
".",
"equals",
"(",
"wlp",
".",
"getLowerCaseShortName",
"(",
")",
")",
")",
"{",
"reqs",
".",
"setVersionDisplayString",
"(",
"minJava11",
")",
";",
"return",
";",
"}",
"// The min version should have been validated when the ESA was constructed",
"// so checking for the version string should be safe",
"if",
"(",
"minVersion",
".",
"equals",
"(",
"\"1.6.0\"",
")",
")",
"{",
"reqs",
".",
"setVersionDisplayString",
"(",
"minJava6",
")",
";",
"return",
";",
"}",
"if",
"(",
"minVersion",
".",
"equals",
"(",
"\"1.7.0\"",
")",
")",
"{",
"reqs",
".",
"setVersionDisplayString",
"(",
"minJava7",
")",
";",
"return",
";",
"}",
"if",
"(",
"minVersion",
".",
"equals",
"(",
"\"1.8.0\"",
")",
")",
"{",
"reqs",
".",
"setVersionDisplayString",
"(",
"minJava8",
")",
";",
"return",
";",
"}",
"if",
"(",
"minVersion",
".",
"startsWith",
"(",
"\"9.\"",
")",
"||",
"minVersion",
".",
"startsWith",
"(",
"\"10.\"",
")",
"||",
"minVersion",
".",
"startsWith",
"(",
"\"11.\"",
")",
")",
"{",
"// If a feature requires a min of Java 9/10/11, state Java 11 is required because",
"// Liberty does not officially support Java 9 or 10",
"reqs",
".",
"setVersionDisplayString",
"(",
"minJava11",
")",
";",
"return",
";",
"}",
"// The min version string has been generated/validated incorrectly",
"// Can't recover from this, it is a bug in EsaUploader",
"throw",
"new",
"AssertionError",
"(",
"\"Unrecognized java version: \"",
"+",
"minVersion",
")",
";",
"}"
] | This generates the string that should be displayed on the website to indicate
the supported Java versions. The requirements come from the bundle manifests.
The mapping between the two is non-obvious, as it is the intersection between
the Java EE requirement and the versions of Java that Liberty supports. | [
"This",
"generates",
"the",
"string",
"that",
"should",
"be",
"displayed",
"on",
"the",
"website",
"to",
"indicate",
"the",
"supported",
"Java",
"versions",
".",
"The",
"requirements",
"come",
"from",
"the",
"bundle",
"manifests",
".",
"The",
"mapping",
"between",
"the",
"two",
"is",
"non",
"-",
"obvious",
"as",
"it",
"is",
"the",
"intersection",
"between",
"the",
"Java",
"EE",
"requirement",
"and",
"the",
"versions",
"of",
"Java",
"that",
"Liberty",
"supports",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.repository/src/com/ibm/ws/repository/resources/internal/EsaResourceImpl.java#L221-L274 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.repository/src/com/ibm/ws/repository/resources/internal/EsaResourceImpl.java | EsaResourceImpl.removeRequireFeatureWithToleratesIfExists | private void removeRequireFeatureWithToleratesIfExists(String feature) {
Collection<RequireFeatureWithTolerates> rfwt = _asset.getWlpInformation().getRequireFeatureWithTolerates();
if (rfwt != null) {
for (RequireFeatureWithTolerates toCheck : rfwt) {
if (toCheck.getFeature().equals(feature)) {
rfwt.remove(toCheck);
return;
}
}
}
} | java | private void removeRequireFeatureWithToleratesIfExists(String feature) {
Collection<RequireFeatureWithTolerates> rfwt = _asset.getWlpInformation().getRequireFeatureWithTolerates();
if (rfwt != null) {
for (RequireFeatureWithTolerates toCheck : rfwt) {
if (toCheck.getFeature().equals(feature)) {
rfwt.remove(toCheck);
return;
}
}
}
} | [
"private",
"void",
"removeRequireFeatureWithToleratesIfExists",
"(",
"String",
"feature",
")",
"{",
"Collection",
"<",
"RequireFeatureWithTolerates",
">",
"rfwt",
"=",
"_asset",
".",
"getWlpInformation",
"(",
")",
".",
"getRequireFeatureWithTolerates",
"(",
")",
";",
"if",
"(",
"rfwt",
"!=",
"null",
")",
"{",
"for",
"(",
"RequireFeatureWithTolerates",
"toCheck",
":",
"rfwt",
")",
"{",
"if",
"(",
"toCheck",
".",
"getFeature",
"(",
")",
".",
"equals",
"(",
"feature",
")",
")",
"{",
"rfwt",
".",
"remove",
"(",
"toCheck",
")",
";",
"return",
";",
"}",
"}",
"}",
"}"
] | Looks in the underlying asset to see if there is a requireFeatureWithTolerates entry for
the supplied feature, and if there is, removes it. | [
"Looks",
"in",
"the",
"underlying",
"asset",
"to",
"see",
"if",
"there",
"is",
"a",
"requireFeatureWithTolerates",
"entry",
"for",
"the",
"supplied",
"feature",
"and",
"if",
"there",
"is",
"removes",
"it",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.repository/src/com/ibm/ws/repository/resources/internal/EsaResourceImpl.java#L489-L499 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.repository/src/com/ibm/ws/repository/resources/internal/EsaResourceImpl.java | EsaResourceImpl.copyRequireFeatureToRequireFeatureWithTolerates | private void copyRequireFeatureToRequireFeatureWithTolerates() {
Collection<RequireFeatureWithTolerates> rfwt = _asset.getWlpInformation().getRequireFeatureWithTolerates();
if (rfwt != null) {
// Both fields (with and without tolerates) should exist, as
// rfwt should not be created unless the other field is created first.
// No need to copy, as the two fields should always be in sync
return;
}
Collection<String> requireFeature = _asset.getWlpInformation().getRequireFeature();
if (requireFeature == null) {
// Neither field exists, no need to copy
return;
}
// We have the requireFeature field but not rfwt, so copy info into
// the new field (rfwt).
Collection<RequireFeatureWithTolerates> newOne = new HashSet<RequireFeatureWithTolerates>();
for (String feature : requireFeature) {
RequireFeatureWithTolerates newFeature = new RequireFeatureWithTolerates();
newFeature.setFeature(feature);
newFeature.setTolerates(Collections.<String> emptyList());
newOne.add(newFeature);
}
_asset.getWlpInformation().setRequireFeatureWithTolerates(newOne);
} | java | private void copyRequireFeatureToRequireFeatureWithTolerates() {
Collection<RequireFeatureWithTolerates> rfwt = _asset.getWlpInformation().getRequireFeatureWithTolerates();
if (rfwt != null) {
// Both fields (with and without tolerates) should exist, as
// rfwt should not be created unless the other field is created first.
// No need to copy, as the two fields should always be in sync
return;
}
Collection<String> requireFeature = _asset.getWlpInformation().getRequireFeature();
if (requireFeature == null) {
// Neither field exists, no need to copy
return;
}
// We have the requireFeature field but not rfwt, so copy info into
// the new field (rfwt).
Collection<RequireFeatureWithTolerates> newOne = new HashSet<RequireFeatureWithTolerates>();
for (String feature : requireFeature) {
RequireFeatureWithTolerates newFeature = new RequireFeatureWithTolerates();
newFeature.setFeature(feature);
newFeature.setTolerates(Collections.<String> emptyList());
newOne.add(newFeature);
}
_asset.getWlpInformation().setRequireFeatureWithTolerates(newOne);
} | [
"private",
"void",
"copyRequireFeatureToRequireFeatureWithTolerates",
"(",
")",
"{",
"Collection",
"<",
"RequireFeatureWithTolerates",
">",
"rfwt",
"=",
"_asset",
".",
"getWlpInformation",
"(",
")",
".",
"getRequireFeatureWithTolerates",
"(",
")",
";",
"if",
"(",
"rfwt",
"!=",
"null",
")",
"{",
"// Both fields (with and without tolerates) should exist, as",
"// rfwt should not be created unless the other field is created first.",
"// No need to copy, as the two fields should always be in sync",
"return",
";",
"}",
"Collection",
"<",
"String",
">",
"requireFeature",
"=",
"_asset",
".",
"getWlpInformation",
"(",
")",
".",
"getRequireFeature",
"(",
")",
";",
"if",
"(",
"requireFeature",
"==",
"null",
")",
"{",
"// Neither field exists, no need to copy",
"return",
";",
"}",
"// We have the requireFeature field but not rfwt, so copy info into",
"// the new field (rfwt).",
"Collection",
"<",
"RequireFeatureWithTolerates",
">",
"newOne",
"=",
"new",
"HashSet",
"<",
"RequireFeatureWithTolerates",
">",
"(",
")",
";",
"for",
"(",
"String",
"feature",
":",
"requireFeature",
")",
"{",
"RequireFeatureWithTolerates",
"newFeature",
"=",
"new",
"RequireFeatureWithTolerates",
"(",
")",
";",
"newFeature",
".",
"setFeature",
"(",
"feature",
")",
";",
"newFeature",
".",
"setTolerates",
"(",
"Collections",
".",
"<",
"String",
">",
"emptyList",
"(",
")",
")",
";",
"newOne",
".",
"add",
"(",
"newFeature",
")",
";",
"}",
"_asset",
".",
"getWlpInformation",
"(",
")",
".",
"setRequireFeatureWithTolerates",
"(",
"newOne",
")",
";",
"}"
] | requireFeature was the old field in the asset which didn't contain tolerates information.
The new field is requireFeatureWithTolerates, and for the moment, both fields are being
maintained, as older assets in the repository will only have the older field. When older assets
are being written to, the data from the older field needs to be copied to the new field, to ensure
both are consistent.
The write will then write to both fields | [
"requireFeature",
"was",
"the",
"old",
"field",
"in",
"the",
"asset",
"which",
"didn",
"t",
"contain",
"tolerates",
"information",
".",
"The",
"new",
"field",
"is",
"requireFeatureWithTolerates",
"and",
"for",
"the",
"moment",
"both",
"fields",
"are",
"being",
"maintained",
"as",
"older",
"assets",
"in",
"the",
"repository",
"will",
"only",
"have",
"the",
"older",
"field",
".",
"When",
"older",
"assets",
"are",
"being",
"written",
"to",
"the",
"data",
"from",
"the",
"older",
"field",
"needs",
"to",
"be",
"copied",
"to",
"the",
"new",
"field",
"to",
"ensure",
"both",
"are",
"consistent",
".",
"The",
"write",
"will",
"then",
"write",
"to",
"both",
"fields"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.repository/src/com/ibm/ws/repository/resources/internal/EsaResourceImpl.java#L509-L534 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.cdi.1.2.weld/src/com/ibm/ws/cdi/utils/WeldCDIUtils.java | WeldCDIUtils.isClassVetoed | public static boolean isClassVetoed(Class<?> type) {
if (type.isAnnotationPresent(Vetoed.class)) {
return true;
}
return isPackageVetoed(type.getPackage());
} | java | public static boolean isClassVetoed(Class<?> type) {
if (type.isAnnotationPresent(Vetoed.class)) {
return true;
}
return isPackageVetoed(type.getPackage());
} | [
"public",
"static",
"boolean",
"isClassVetoed",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"if",
"(",
"type",
".",
"isAnnotationPresent",
"(",
"Vetoed",
".",
"class",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"isPackageVetoed",
"(",
"type",
".",
"getPackage",
"(",
")",
")",
";",
"}"
] | Return true if the class is vetoed or the package is vetoed
@param type class
@return true if the class is vetoed or the package is vetoed, false otherwise | [
"Return",
"true",
"if",
"the",
"class",
"is",
"vetoed",
"or",
"the",
"package",
"is",
"vetoed"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.cdi.1.2.weld/src/com/ibm/ws/cdi/utils/WeldCDIUtils.java#L52-L57 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java | TwitterEndpointServices.populateCommonAuthzHeaderParams | private Map<String, String> populateCommonAuthzHeaderParams() {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(TwitterConstants.PARAM_OAUTH_CONSUMER_KEY, consumerKey);
parameters.put(TwitterConstants.PARAM_OAUTH_NONCE, Utils.generateNonce());
parameters.put(TwitterConstants.PARAM_OAUTH_SIGNATURE_METHOD, DEFAULT_SIGNATURE_ALGORITHM);
parameters.put(TwitterConstants.PARAM_OAUTH_TIMESTAMP, Utils.getCurrentTimestamp());
parameters.put(TwitterConstants.PARAM_OAUTH_VERSION, DEFAULT_OAUTH_VERSION);
return parameters;
} | java | private Map<String, String> populateCommonAuthzHeaderParams() {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(TwitterConstants.PARAM_OAUTH_CONSUMER_KEY, consumerKey);
parameters.put(TwitterConstants.PARAM_OAUTH_NONCE, Utils.generateNonce());
parameters.put(TwitterConstants.PARAM_OAUTH_SIGNATURE_METHOD, DEFAULT_SIGNATURE_ALGORITHM);
parameters.put(TwitterConstants.PARAM_OAUTH_TIMESTAMP, Utils.getCurrentTimestamp());
parameters.put(TwitterConstants.PARAM_OAUTH_VERSION, DEFAULT_OAUTH_VERSION);
return parameters;
} | [
"private",
"Map",
"<",
"String",
",",
"String",
">",
"populateCommonAuthzHeaderParams",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"parameters",
".",
"put",
"(",
"TwitterConstants",
".",
"PARAM_OAUTH_CONSUMER_KEY",
",",
"consumerKey",
")",
";",
"parameters",
".",
"put",
"(",
"TwitterConstants",
".",
"PARAM_OAUTH_NONCE",
",",
"Utils",
".",
"generateNonce",
"(",
")",
")",
";",
"parameters",
".",
"put",
"(",
"TwitterConstants",
".",
"PARAM_OAUTH_SIGNATURE_METHOD",
",",
"DEFAULT_SIGNATURE_ALGORITHM",
")",
";",
"parameters",
".",
"put",
"(",
"TwitterConstants",
".",
"PARAM_OAUTH_TIMESTAMP",
",",
"Utils",
".",
"getCurrentTimestamp",
"(",
")",
")",
";",
"parameters",
".",
"put",
"(",
"TwitterConstants",
".",
"PARAM_OAUTH_VERSION",
",",
"DEFAULT_OAUTH_VERSION",
")",
";",
"return",
"parameters",
";",
"}"
] | Creates a map of parameters and values that are common to all requests that require an Authorization header.
@return | [
"Creates",
"a",
"map",
"of",
"parameters",
"and",
"values",
"that",
"are",
"common",
"to",
"all",
"requests",
"that",
"require",
"an",
"Authorization",
"header",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java#L368-L378 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java | TwitterEndpointServices.signAndCreateAuthzHeader | private String signAndCreateAuthzHeader(String endpointUrl, Map<String, String> parameters) {
String signature = computeSignature(requestMethod, endpointUrl, parameters);
parameters.put(TwitterConstants.PARAM_OAUTH_SIGNATURE, signature);
String authzHeaderString = createAuthorizationHeaderString(parameters);
return authzHeaderString;
} | java | private String signAndCreateAuthzHeader(String endpointUrl, Map<String, String> parameters) {
String signature = computeSignature(requestMethod, endpointUrl, parameters);
parameters.put(TwitterConstants.PARAM_OAUTH_SIGNATURE, signature);
String authzHeaderString = createAuthorizationHeaderString(parameters);
return authzHeaderString;
} | [
"private",
"String",
"signAndCreateAuthzHeader",
"(",
"String",
"endpointUrl",
",",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"{",
"String",
"signature",
"=",
"computeSignature",
"(",
"requestMethod",
",",
"endpointUrl",
",",
"parameters",
")",
";",
"parameters",
".",
"put",
"(",
"TwitterConstants",
".",
"PARAM_OAUTH_SIGNATURE",
",",
"signature",
")",
";",
"String",
"authzHeaderString",
"=",
"createAuthorizationHeaderString",
"(",
"parameters",
")",
";",
"return",
"authzHeaderString",
";",
"}"
] | Generates the Authorization header with all the requisite content for the specified endpoint request by computing the
signature, adding it to the parameters, and generating the Authorization header string.
@param endpointUrl
@param parameters
@return | [
"Generates",
"the",
"Authorization",
"header",
"with",
"all",
"the",
"requisite",
"content",
"for",
"the",
"specified",
"endpoint",
"request",
"by",
"computing",
"the",
"signature",
"adding",
"it",
"to",
"the",
"parameters",
"and",
"generating",
"the",
"Authorization",
"header",
"string",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java#L408-L415 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java | TwitterEndpointServices.populateJsonResponse | public Map<String, Object> populateJsonResponse(String responseBody) throws JoseException {
if (responseBody == null || responseBody.isEmpty()) {
return null;
}
return JsonUtil.parseJson(responseBody);
} | java | public Map<String, Object> populateJsonResponse(String responseBody) throws JoseException {
if (responseBody == null || responseBody.isEmpty()) {
return null;
}
return JsonUtil.parseJson(responseBody);
} | [
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"populateJsonResponse",
"(",
"String",
"responseBody",
")",
"throws",
"JoseException",
"{",
"if",
"(",
"responseBody",
"==",
"null",
"||",
"responseBody",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"JsonUtil",
".",
"parseJson",
"(",
"responseBody",
")",
";",
"}"
] | Populates a Map from the response body. This method expects the responseBody value to be in JSON format.
@param responseBody
@return {@code null} if the response body was {@code null} or empty. Otherwise returns a Map with all entries and values
contained in the response body.
@throws JoseException | [
"Populates",
"a",
"Map",
"from",
"the",
"response",
"body",
".",
"This",
"method",
"expects",
"the",
"responseBody",
"value",
"to",
"be",
"in",
"JSON",
"format",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java#L501-L506 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java | TwitterEndpointServices.executeRequest | @FFDCIgnore(SocialLoginException.class)
@Sensitive
public Map<String, Object> executeRequest(SocialLoginConfig config, String requestMethod, String authzHeaderString, String url, String endpointType, String verifierValue) {
if (endpointType == null) {
endpointType = TwitterConstants.TWITTER_ENDPOINT_REQUEST_TOKEN;
if (tc.isDebugEnabled()) {
Tr.debug(tc, "A Twitter endpoint path was not found; defaulting to using " + endpointType + " as the Twitter endpoint path.");
}
}
try {
SocialUtil.validateEndpointWithQuery(url);
} catch (SocialLoginException e) {
return createErrorResponse(e);
}
StringBuilder uri = new StringBuilder(url);
if (endpointType.equals(TwitterConstants.TWITTER_ENDPOINT_VERIFY_CREDENTIALS)) {
// Include the include_email and skip_status parameters for these endpoint requests
uri.append("?").append(TwitterConstants.PARAM_INCLUDE_EMAIL).append("=").append(TwitterConstants.INCLUDE_EMAIL).append("&").append(TwitterConstants.PARAM_SKIP_STATUS).append("=").append(TwitterConstants.SKIP_STATUS);
}
try {
Map<String, Object> result = getEndpointResponse(config, uri.toString(), requestMethod, authzHeaderString, endpointType, verifierValue);
String responseContent = httpUtil.extractTokensFromResponse(result);
return evaluateRequestResponse(responseContent, endpointType);
} catch (SocialLoginException e) {
return createErrorResponse("TWITTER_EXCEPTION_EXECUTING_REQUEST", new Object[] { url, e.getLocalizedMessage() });
}
} | java | @FFDCIgnore(SocialLoginException.class)
@Sensitive
public Map<String, Object> executeRequest(SocialLoginConfig config, String requestMethod, String authzHeaderString, String url, String endpointType, String verifierValue) {
if (endpointType == null) {
endpointType = TwitterConstants.TWITTER_ENDPOINT_REQUEST_TOKEN;
if (tc.isDebugEnabled()) {
Tr.debug(tc, "A Twitter endpoint path was not found; defaulting to using " + endpointType + " as the Twitter endpoint path.");
}
}
try {
SocialUtil.validateEndpointWithQuery(url);
} catch (SocialLoginException e) {
return createErrorResponse(e);
}
StringBuilder uri = new StringBuilder(url);
if (endpointType.equals(TwitterConstants.TWITTER_ENDPOINT_VERIFY_CREDENTIALS)) {
// Include the include_email and skip_status parameters for these endpoint requests
uri.append("?").append(TwitterConstants.PARAM_INCLUDE_EMAIL).append("=").append(TwitterConstants.INCLUDE_EMAIL).append("&").append(TwitterConstants.PARAM_SKIP_STATUS).append("=").append(TwitterConstants.SKIP_STATUS);
}
try {
Map<String, Object> result = getEndpointResponse(config, uri.toString(), requestMethod, authzHeaderString, endpointType, verifierValue);
String responseContent = httpUtil.extractTokensFromResponse(result);
return evaluateRequestResponse(responseContent, endpointType);
} catch (SocialLoginException e) {
return createErrorResponse("TWITTER_EXCEPTION_EXECUTING_REQUEST", new Object[] { url, e.getLocalizedMessage() });
}
} | [
"@",
"FFDCIgnore",
"(",
"SocialLoginException",
".",
"class",
")",
"@",
"Sensitive",
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"executeRequest",
"(",
"SocialLoginConfig",
"config",
",",
"String",
"requestMethod",
",",
"String",
"authzHeaderString",
",",
"String",
"url",
",",
"String",
"endpointType",
",",
"String",
"verifierValue",
")",
"{",
"if",
"(",
"endpointType",
"==",
"null",
")",
"{",
"endpointType",
"=",
"TwitterConstants",
".",
"TWITTER_ENDPOINT_REQUEST_TOKEN",
";",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"A Twitter endpoint path was not found; defaulting to using \"",
"+",
"endpointType",
"+",
"\" as the Twitter endpoint path.\"",
")",
";",
"}",
"}",
"try",
"{",
"SocialUtil",
".",
"validateEndpointWithQuery",
"(",
"url",
")",
";",
"}",
"catch",
"(",
"SocialLoginException",
"e",
")",
"{",
"return",
"createErrorResponse",
"(",
"e",
")",
";",
"}",
"StringBuilder",
"uri",
"=",
"new",
"StringBuilder",
"(",
"url",
")",
";",
"if",
"(",
"endpointType",
".",
"equals",
"(",
"TwitterConstants",
".",
"TWITTER_ENDPOINT_VERIFY_CREDENTIALS",
")",
")",
"{",
"// Include the include_email and skip_status parameters for these endpoint requests",
"uri",
".",
"append",
"(",
"\"?\"",
")",
".",
"append",
"(",
"TwitterConstants",
".",
"PARAM_INCLUDE_EMAIL",
")",
".",
"append",
"(",
"\"=\"",
")",
".",
"append",
"(",
"TwitterConstants",
".",
"INCLUDE_EMAIL",
")",
".",
"append",
"(",
"\"&\"",
")",
".",
"append",
"(",
"TwitterConstants",
".",
"PARAM_SKIP_STATUS",
")",
".",
"append",
"(",
"\"=\"",
")",
".",
"append",
"(",
"TwitterConstants",
".",
"SKIP_STATUS",
")",
";",
"}",
"try",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
"=",
"getEndpointResponse",
"(",
"config",
",",
"uri",
".",
"toString",
"(",
")",
",",
"requestMethod",
",",
"authzHeaderString",
",",
"endpointType",
",",
"verifierValue",
")",
";",
"String",
"responseContent",
"=",
"httpUtil",
".",
"extractTokensFromResponse",
"(",
"result",
")",
";",
"return",
"evaluateRequestResponse",
"(",
"responseContent",
",",
"endpointType",
")",
";",
"}",
"catch",
"(",
"SocialLoginException",
"e",
")",
"{",
"return",
"createErrorResponse",
"(",
"\"TWITTER_EXCEPTION_EXECUTING_REQUEST\"",
",",
"new",
"Object",
"[",
"]",
"{",
"url",
",",
"e",
".",
"getLocalizedMessage",
"(",
")",
"}",
")",
";",
"}",
"}"
] | Sends a request to the specified Twitter endpoint and returns a Map object containing the evaluated response.
@param config
@param requestMethod
@param authzHeaderString
@param url
@param endpointType
@param verifierValue
Only used for {@value TwitterConstants#TWITTER_ENDPOINT_ACCESS_TOKEN} requests
@return | [
"Sends",
"a",
"request",
"to",
"the",
"specified",
"Twitter",
"endpoint",
"and",
"returns",
"a",
"Map",
"object",
"containing",
"the",
"evaluated",
"response",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java#L832-L865 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java | ZipFileArtifactNotifier.updateMonitorService | @FFDCIgnore(IllegalStateException.class)
private void updateMonitorService() {
if ( !coveringPaths.isEmpty() ) {
if ( service == null ) {
try {
// If we are shutting down, we want to generate the exception quickly.
BundleContext bundleContext = getContainerFactoryHolder().getBundleContext();
// throws 'IllegalStateException'
setServiceProperties();
service = bundleContext.registerService(FileMonitor.class, this, serviceProperties);
// See comments on 'loadZipEntries' for why the entries must be loaded now.
loadZipEntries();
} catch ( IllegalStateException e ) {
// Ignore; the framework is shutting down.
}
} else {
// Do nothing: There is already a service registration.
}
} else {
if ( service != null ) {
try {
service.unregister();
} catch ( IllegalStateException e ) {
// Ignore; framework is shutting down.
}
service = null;
} else {
// Do nothing: There is already no service registration.
}
}
} | java | @FFDCIgnore(IllegalStateException.class)
private void updateMonitorService() {
if ( !coveringPaths.isEmpty() ) {
if ( service == null ) {
try {
// If we are shutting down, we want to generate the exception quickly.
BundleContext bundleContext = getContainerFactoryHolder().getBundleContext();
// throws 'IllegalStateException'
setServiceProperties();
service = bundleContext.registerService(FileMonitor.class, this, serviceProperties);
// See comments on 'loadZipEntries' for why the entries must be loaded now.
loadZipEntries();
} catch ( IllegalStateException e ) {
// Ignore; the framework is shutting down.
}
} else {
// Do nothing: There is already a service registration.
}
} else {
if ( service != null ) {
try {
service.unregister();
} catch ( IllegalStateException e ) {
// Ignore; framework is shutting down.
}
service = null;
} else {
// Do nothing: There is already no service registration.
}
}
} | [
"@",
"FFDCIgnore",
"(",
"IllegalStateException",
".",
"class",
")",
"private",
"void",
"updateMonitorService",
"(",
")",
"{",
"if",
"(",
"!",
"coveringPaths",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"service",
"==",
"null",
")",
"{",
"try",
"{",
"// If we are shutting down, we want to generate the exception quickly.",
"BundleContext",
"bundleContext",
"=",
"getContainerFactoryHolder",
"(",
")",
".",
"getBundleContext",
"(",
")",
";",
"// throws 'IllegalStateException'",
"setServiceProperties",
"(",
")",
";",
"service",
"=",
"bundleContext",
".",
"registerService",
"(",
"FileMonitor",
".",
"class",
",",
"this",
",",
"serviceProperties",
")",
";",
"// See comments on 'loadZipEntries' for why the entries must be loaded now.",
"loadZipEntries",
"(",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"// Ignore; the framework is shutting down.",
"}",
"}",
"else",
"{",
"// Do nothing: There is already a service registration.",
"}",
"}",
"else",
"{",
"if",
"(",
"service",
"!=",
"null",
")",
"{",
"try",
"{",
"service",
".",
"unregister",
"(",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"// Ignore; framework is shutting down.",
"}",
"service",
"=",
"null",
";",
"}",
"else",
"{",
"// Do nothing: There is already no service registration.",
"}",
"}",
"}"
] | Update the monitor service according to whether any listeners
are registered. That is, if any covering paths are present.
When listeners are registered, register the file monitor as
a service. When no listeners are registered, unregister the
file monitor as a service.
Registration as a service is only done when the notifier is
an exposed notifier. For a non-exposed notifier, see
{@link #updateEnclosingMonitor}. | [
"Update",
"the",
"monitor",
"service",
"according",
"to",
"whether",
"any",
"listeners",
"are",
"registered",
".",
"That",
"is",
"if",
"any",
"covering",
"paths",
"are",
"present",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java#L264-L298 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java | ZipFileArtifactNotifier.updateEnclosingMonitor | private void updateEnclosingMonitor() {
if ( !coveringPaths.isEmpty() ) {
if ( !listenerRegistered ) {
// This container is not yet registered to the enclosing container.
// Register this container.
ArtifactContainer enclosingRootContainer = entryInEnclosingContainer.getRoot();
// The path to register is the path of the enclosing entry.
ArtifactNotification enclosingNotification = new DefaultArtifactNotification(
enclosingRootContainer,
Collections.singleton( entryInEnclosingContainer.getPath() ) );
ArtifactNotifier enclosingRootNotifier = enclosingRootContainer.getArtifactNotifier();
// The enclosing container generally will accept the registration
// request. Just in case it doesn't, set the registration flag
// based on the registration result.
listenerRegistered = enclosingRootNotifier.registerForNotifications(enclosingNotification, this);
// The result is that any change to the enclosing container reaches
// this notifier through 'notifyEntryChange'.
// See comments on 'loadZipEntries' for why the entries must be loaded now.
loadZipEntries();
} else {
// Do nothing: The enclosing entry was already registered
// to the enclosing notifier.
}
} else {
if ( listenerRegistered ) {
// There are no listener registrations active on this container.
// Remove the registration of this listener.
//
// This listener should be registered exactly once to the enclosing
// container: Removing all registrations of this listener should remove
// that one registration, with no addition, unwanted registration changes.
ArtifactContainer enclosingRootContainer = entryInEnclosingContainer.getRoot();
ArtifactNotifier enclosingNotifier = enclosingRootContainer.getArtifactNotifier();
enclosingNotifier.removeListener(this);
} else {
// Do nothing: The enclosing monitor already did not have a registration
// for this container.
}
}
} | java | private void updateEnclosingMonitor() {
if ( !coveringPaths.isEmpty() ) {
if ( !listenerRegistered ) {
// This container is not yet registered to the enclosing container.
// Register this container.
ArtifactContainer enclosingRootContainer = entryInEnclosingContainer.getRoot();
// The path to register is the path of the enclosing entry.
ArtifactNotification enclosingNotification = new DefaultArtifactNotification(
enclosingRootContainer,
Collections.singleton( entryInEnclosingContainer.getPath() ) );
ArtifactNotifier enclosingRootNotifier = enclosingRootContainer.getArtifactNotifier();
// The enclosing container generally will accept the registration
// request. Just in case it doesn't, set the registration flag
// based on the registration result.
listenerRegistered = enclosingRootNotifier.registerForNotifications(enclosingNotification, this);
// The result is that any change to the enclosing container reaches
// this notifier through 'notifyEntryChange'.
// See comments on 'loadZipEntries' for why the entries must be loaded now.
loadZipEntries();
} else {
// Do nothing: The enclosing entry was already registered
// to the enclosing notifier.
}
} else {
if ( listenerRegistered ) {
// There are no listener registrations active on this container.
// Remove the registration of this listener.
//
// This listener should be registered exactly once to the enclosing
// container: Removing all registrations of this listener should remove
// that one registration, with no addition, unwanted registration changes.
ArtifactContainer enclosingRootContainer = entryInEnclosingContainer.getRoot();
ArtifactNotifier enclosingNotifier = enclosingRootContainer.getArtifactNotifier();
enclosingNotifier.removeListener(this);
} else {
// Do nothing: The enclosing monitor already did not have a registration
// for this container.
}
}
} | [
"private",
"void",
"updateEnclosingMonitor",
"(",
")",
"{",
"if",
"(",
"!",
"coveringPaths",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"!",
"listenerRegistered",
")",
"{",
"// This container is not yet registered to the enclosing container.",
"// Register this container.",
"ArtifactContainer",
"enclosingRootContainer",
"=",
"entryInEnclosingContainer",
".",
"getRoot",
"(",
")",
";",
"// The path to register is the path of the enclosing entry.",
"ArtifactNotification",
"enclosingNotification",
"=",
"new",
"DefaultArtifactNotification",
"(",
"enclosingRootContainer",
",",
"Collections",
".",
"singleton",
"(",
"entryInEnclosingContainer",
".",
"getPath",
"(",
")",
")",
")",
";",
"ArtifactNotifier",
"enclosingRootNotifier",
"=",
"enclosingRootContainer",
".",
"getArtifactNotifier",
"(",
")",
";",
"// The enclosing container generally will accept the registration",
"// request. Just in case it doesn't, set the registration flag",
"// based on the registration result.",
"listenerRegistered",
"=",
"enclosingRootNotifier",
".",
"registerForNotifications",
"(",
"enclosingNotification",
",",
"this",
")",
";",
"// The result is that any change to the enclosing container reaches",
"// this notifier through 'notifyEntryChange'.",
"// See comments on 'loadZipEntries' for why the entries must be loaded now.",
"loadZipEntries",
"(",
")",
";",
"}",
"else",
"{",
"// Do nothing: The enclosing entry was already registered",
"// to the enclosing notifier.",
"}",
"}",
"else",
"{",
"if",
"(",
"listenerRegistered",
")",
"{",
"// There are no listener registrations active on this container.",
"// Remove the registration of this listener.",
"//",
"// This listener should be registered exactly once to the enclosing",
"// container: Removing all registrations of this listener should remove",
"// that one registration, with no addition, unwanted registration changes.",
"ArtifactContainer",
"enclosingRootContainer",
"=",
"entryInEnclosingContainer",
".",
"getRoot",
"(",
")",
";",
"ArtifactNotifier",
"enclosingNotifier",
"=",
"enclosingRootContainer",
".",
"getArtifactNotifier",
"(",
")",
";",
"enclosingNotifier",
".",
"removeListener",
"(",
"this",
")",
";",
"}",
"else",
"{",
"// Do nothing: The enclosing monitor already did not have a registration",
"// for this container.",
"}",
"}",
"}"
] | Update the enclosing monitor according to whether any listeners
are registered. That is, if any covering paths are present.
When listeners are registered, register the this notifier as
a listener on the enclosing entry. When no listeners are
registered, remove this notifier as a listener on the enclosing
entry.
Registration as a listener is only done when the notifier is
a non-exposed notifier. For an exposed notifier, see
{@link #updateMonitorService}. | [
"Update",
"the",
"enclosing",
"monitor",
"according",
"to",
"whether",
"any",
"listeners",
"are",
"registered",
".",
"That",
"is",
"if",
"any",
"covering",
"paths",
"are",
"present",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java#L313-L362 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java | ZipFileArtifactNotifier.registerListener | private boolean registerListener(String newPath, ArtifactListenerSelector newListener) {
boolean updatedCoveringPaths = addCoveringPath(newPath);
Collection<ArtifactListenerSelector> listenersForPath = listeners.get(newPath);
if ( listenersForPath == null ) {
// Each listeners collection is expected to be small.
listenersForPath = new LinkedList<ArtifactListenerSelector>();
listeners.put(newPath, listenersForPath);
}
listenersForPath.add(newListener);
return ( updatedCoveringPaths );
} | java | private boolean registerListener(String newPath, ArtifactListenerSelector newListener) {
boolean updatedCoveringPaths = addCoveringPath(newPath);
Collection<ArtifactListenerSelector> listenersForPath = listeners.get(newPath);
if ( listenersForPath == null ) {
// Each listeners collection is expected to be small.
listenersForPath = new LinkedList<ArtifactListenerSelector>();
listeners.put(newPath, listenersForPath);
}
listenersForPath.add(newListener);
return ( updatedCoveringPaths );
} | [
"private",
"boolean",
"registerListener",
"(",
"String",
"newPath",
",",
"ArtifactListenerSelector",
"newListener",
")",
"{",
"boolean",
"updatedCoveringPaths",
"=",
"addCoveringPath",
"(",
"newPath",
")",
";",
"Collection",
"<",
"ArtifactListenerSelector",
">",
"listenersForPath",
"=",
"listeners",
".",
"get",
"(",
"newPath",
")",
";",
"if",
"(",
"listenersForPath",
"==",
"null",
")",
"{",
"// Each listeners collection is expected to be small.",
"listenersForPath",
"=",
"new",
"LinkedList",
"<",
"ArtifactListenerSelector",
">",
"(",
")",
";",
"listeners",
".",
"put",
"(",
"newPath",
",",
"listenersForPath",
")",
";",
"}",
"listenersForPath",
".",
"add",
"(",
"newListener",
")",
";",
"return",
"(",
"updatedCoveringPaths",
")",
";",
"}"
] | Register a listener to a specified path.
Registration has two effects: The listener is put into a table
which maps the listener to specified path. The path of the
listener are added to the covering paths collection, possibly
causing newly covered paths to be removed from the collection.
If the new path is already covered, the covering paths
collection is not changed.
@param newPath The path to which to register the listener.
@param newListener The listener which is to be registered.
@return True or false telling if the uncovered paths collection
was updated. | [
"Register",
"a",
"listener",
"to",
"a",
"specified",
"path",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java#L465-L477 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java | ZipFileArtifactNotifier.addCoveringPath | private boolean addCoveringPath(String newPath) {
int newLen = newPath.length();
Iterator<String> useCoveringPaths = coveringPaths.iterator();
boolean isCovered = false;
boolean isCovering = false;
while ( !isCovered && useCoveringPaths.hasNext() ) {
String coveringPath = useCoveringPaths.next();
int coveringLen = coveringPath.length();
if ( coveringLen < newLen ) {
if ( isCovering ) {
continue; // Can't be covered.
} else {
if ( newPath.regionMatches(0, coveringPath, 0, coveringLen) ) {
if ( newPath.charAt(coveringLen) == '/' ) {
isCovered = true; // Covered: "covering/child" vs "covering"
break; // No need to continue: Can't be any additional relationships to find.
} else {
continue; // Dissimilar: "coveringX" vs "covering"
}
} else {
continue; // Dissimilar: "coverXngX" vs "covering"
}
}
} else if ( coveringLen == newLen ) {
if ( isCovering ) {
continue; // Can't be covered
} else {
if ( newPath.regionMatches(0, coveringPath, 0, coveringLen) ) {
isCovered = true; // Covered: "covering" vs "covering"
break; // No need to continue: Can't be any additional relationships to find.
} else {
continue; // "covering" vs "coverXng"
}
}
} else { // coveringLen > newLen
if ( newPath.regionMatches(0, coveringPath, 0, newLen) ) {
if ( coveringPath.charAt(newLen) == '/' ) {
isCovering = true;
useCoveringPaths.remove(); // Covering: "covering" vs "covering/child"
continue; // Look for other independent children: "covering/child1" and "covering/child2"
} else {
continue; // Dissimilar: "covering" vs "coveringX"
}
} else {
continue; // Dissimilar: "covering" vs "coverXngX"
}
}
}
if ( !isCovered ) {
coveringPaths.add(newPath);
}
return !isCovered;
} | java | private boolean addCoveringPath(String newPath) {
int newLen = newPath.length();
Iterator<String> useCoveringPaths = coveringPaths.iterator();
boolean isCovered = false;
boolean isCovering = false;
while ( !isCovered && useCoveringPaths.hasNext() ) {
String coveringPath = useCoveringPaths.next();
int coveringLen = coveringPath.length();
if ( coveringLen < newLen ) {
if ( isCovering ) {
continue; // Can't be covered.
} else {
if ( newPath.regionMatches(0, coveringPath, 0, coveringLen) ) {
if ( newPath.charAt(coveringLen) == '/' ) {
isCovered = true; // Covered: "covering/child" vs "covering"
break; // No need to continue: Can't be any additional relationships to find.
} else {
continue; // Dissimilar: "coveringX" vs "covering"
}
} else {
continue; // Dissimilar: "coverXngX" vs "covering"
}
}
} else if ( coveringLen == newLen ) {
if ( isCovering ) {
continue; // Can't be covered
} else {
if ( newPath.regionMatches(0, coveringPath, 0, coveringLen) ) {
isCovered = true; // Covered: "covering" vs "covering"
break; // No need to continue: Can't be any additional relationships to find.
} else {
continue; // "covering" vs "coverXng"
}
}
} else { // coveringLen > newLen
if ( newPath.regionMatches(0, coveringPath, 0, newLen) ) {
if ( coveringPath.charAt(newLen) == '/' ) {
isCovering = true;
useCoveringPaths.remove(); // Covering: "covering" vs "covering/child"
continue; // Look for other independent children: "covering/child1" and "covering/child2"
} else {
continue; // Dissimilar: "covering" vs "coveringX"
}
} else {
continue; // Dissimilar: "covering" vs "coverXngX"
}
}
}
if ( !isCovered ) {
coveringPaths.add(newPath);
}
return !isCovered;
} | [
"private",
"boolean",
"addCoveringPath",
"(",
"String",
"newPath",
")",
"{",
"int",
"newLen",
"=",
"newPath",
".",
"length",
"(",
")",
";",
"Iterator",
"<",
"String",
">",
"useCoveringPaths",
"=",
"coveringPaths",
".",
"iterator",
"(",
")",
";",
"boolean",
"isCovered",
"=",
"false",
";",
"boolean",
"isCovering",
"=",
"false",
";",
"while",
"(",
"!",
"isCovered",
"&&",
"useCoveringPaths",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"coveringPath",
"=",
"useCoveringPaths",
".",
"next",
"(",
")",
";",
"int",
"coveringLen",
"=",
"coveringPath",
".",
"length",
"(",
")",
";",
"if",
"(",
"coveringLen",
"<",
"newLen",
")",
"{",
"if",
"(",
"isCovering",
")",
"{",
"continue",
";",
"// Can't be covered.",
"}",
"else",
"{",
"if",
"(",
"newPath",
".",
"regionMatches",
"(",
"0",
",",
"coveringPath",
",",
"0",
",",
"coveringLen",
")",
")",
"{",
"if",
"(",
"newPath",
".",
"charAt",
"(",
"coveringLen",
")",
"==",
"'",
"'",
")",
"{",
"isCovered",
"=",
"true",
";",
"// Covered: \"covering/child\" vs \"covering\"",
"break",
";",
"// No need to continue: Can't be any additional relationships to find.",
"}",
"else",
"{",
"continue",
";",
"// Dissimilar: \"coveringX\" vs \"covering\"",
"}",
"}",
"else",
"{",
"continue",
";",
"// Dissimilar: \"coverXngX\" vs \"covering\"",
"}",
"}",
"}",
"else",
"if",
"(",
"coveringLen",
"==",
"newLen",
")",
"{",
"if",
"(",
"isCovering",
")",
"{",
"continue",
";",
"// Can't be covered",
"}",
"else",
"{",
"if",
"(",
"newPath",
".",
"regionMatches",
"(",
"0",
",",
"coveringPath",
",",
"0",
",",
"coveringLen",
")",
")",
"{",
"isCovered",
"=",
"true",
";",
"// Covered: \"covering\" vs \"covering\"",
"break",
";",
"// No need to continue: Can't be any additional relationships to find.",
"}",
"else",
"{",
"continue",
";",
"// \"covering\" vs \"coverXng\"",
"}",
"}",
"}",
"else",
"{",
"// coveringLen > newLen",
"if",
"(",
"newPath",
".",
"regionMatches",
"(",
"0",
",",
"coveringPath",
",",
"0",
",",
"newLen",
")",
")",
"{",
"if",
"(",
"coveringPath",
".",
"charAt",
"(",
"newLen",
")",
"==",
"'",
"'",
")",
"{",
"isCovering",
"=",
"true",
";",
"useCoveringPaths",
".",
"remove",
"(",
")",
";",
"// Covering: \"covering\" vs \"covering/child\"",
"continue",
";",
"// Look for other independent children: \"covering/child1\" and \"covering/child2\"",
"}",
"else",
"{",
"continue",
";",
"// Dissimilar: \"covering\" vs \"coveringX\"",
"}",
"}",
"else",
"{",
"continue",
";",
"// Dissimilar: \"covering\" vs \"coverXngX\"",
"}",
"}",
"}",
"if",
"(",
"!",
"isCovered",
")",
"{",
"coveringPaths",
".",
"add",
"(",
"newPath",
")",
";",
"}",
"return",
"!",
"isCovered",
";",
"}"
] | Add a path to the covering paths collection.
Do nothing if a path in the collection covers the new path.
Add the path and remove any paths covered by the new path
if the path is not covered by a path in the collection.
@param newPath The path to add to the covering paths collection.
@return Answer true or false telling if the covering paths collection
was modified. | [
"Add",
"a",
"path",
"to",
"the",
"covering",
"paths",
"collection",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java#L492-L548 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java | ZipFileArtifactNotifier.validateNotification | @Trivial
private String validateNotification(Collection<?> added, Collection<?> removed, Collection<?> updated) {
boolean isAddition = !added.isEmpty();
boolean isRemoval = !removed.isEmpty();
boolean isUpdate = !updated.isEmpty();
if ( !isAddition && !isRemoval && !isUpdate ) {
// Should never occur:
// Completely null changes are detected and cause an early return
// before reaching the validation method.
return "null";
} else if ( isAddition ) {
return "Addition of [ " + added.toString() + " ]";
} else if ( isUpdate && isRemoval ) {
return "Update of [ " + updated.toString() + " ]" +
" with removal of [ " + removed.toString() + " ]";
} else {
return null;
}
} | java | @Trivial
private String validateNotification(Collection<?> added, Collection<?> removed, Collection<?> updated) {
boolean isAddition = !added.isEmpty();
boolean isRemoval = !removed.isEmpty();
boolean isUpdate = !updated.isEmpty();
if ( !isAddition && !isRemoval && !isUpdate ) {
// Should never occur:
// Completely null changes are detected and cause an early return
// before reaching the validation method.
return "null";
} else if ( isAddition ) {
return "Addition of [ " + added.toString() + " ]";
} else if ( isUpdate && isRemoval ) {
return "Update of [ " + updated.toString() + " ]" +
" with removal of [ " + removed.toString() + " ]";
} else {
return null;
}
} | [
"@",
"Trivial",
"private",
"String",
"validateNotification",
"(",
"Collection",
"<",
"?",
">",
"added",
",",
"Collection",
"<",
"?",
">",
"removed",
",",
"Collection",
"<",
"?",
">",
"updated",
")",
"{",
"boolean",
"isAddition",
"=",
"!",
"added",
".",
"isEmpty",
"(",
")",
";",
"boolean",
"isRemoval",
"=",
"!",
"removed",
".",
"isEmpty",
"(",
")",
";",
"boolean",
"isUpdate",
"=",
"!",
"updated",
".",
"isEmpty",
"(",
")",
";",
"if",
"(",
"!",
"isAddition",
"&&",
"!",
"isRemoval",
"&&",
"!",
"isUpdate",
")",
"{",
"// Should never occur:",
"// Completely null changes are detected and cause an early return",
"// before reaching the validation method.",
"return",
"\"null\"",
";",
"}",
"else",
"if",
"(",
"isAddition",
")",
"{",
"return",
"\"Addition of [ \"",
"+",
"added",
".",
"toString",
"(",
")",
"+",
"\" ]\"",
";",
"}",
"else",
"if",
"(",
"isUpdate",
"&&",
"isRemoval",
")",
"{",
"return",
"\"Update of [ \"",
"+",
"updated",
".",
"toString",
"(",
")",
"+",
"\" ]\"",
"+",
"\" with removal of [ \"",
"+",
"removed",
".",
"toString",
"(",
")",
"+",
"\" ]\"",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Validate change data, which is expected to be collections of files
or collections of entry paths.
Since the single root zip file is registered, the change is expected
to be a single element in exactly one of the change collections.
Null changes are unexpected. Additions are unexpected. Updates with
removals are unexpected.
The net is to allow updates alone or removals alone.
@return A validation message if unexpected changes are noted.
Null if the changes are expected. | [
"Validate",
"change",
"data",
"which",
"is",
"expected",
"to",
"be",
"collections",
"of",
"files",
"or",
"collections",
"of",
"entry",
"paths",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java#L745-L767 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java | ZipFileArtifactNotifier.notifyAllListeners | private void notifyAllListeners(boolean isUpdate, String filter) {
// Can't reuse the registered paths collection across the loop
// because the listener notification can do processing in a new
// thread. Reusing the registered paths could cause a collision
// between the listener thread with this notification processing
// thread.
// TODO: Should the notification step be separated from the listener detection step?
// That might create large data structures, but would prevent the listeners
// from being locked during a possibly extensive steps of the listeners handling
// their notifications.
// TODO: See the comment, below. The notification step has been separated from the
// listener collection step.
List<QueuedNotification> notifications = null;
synchronized( listenersLock ) {
for ( Map.Entry<String, Collection<ArtifactListenerSelector>> listenersEntry : listeners.entrySet() ) {
List<String> a_registeredPaths = new ArrayList<String>();
collectRegisteredPaths( listenersEntry.getKey(), a_registeredPaths );
if ( a_registeredPaths.isEmpty() ) {
continue;
}
ArtifactNotification registeredPaths =
new DefaultArtifactNotification(rootContainer, a_registeredPaths);
for ( ArtifactListenerSelector listener : listenersEntry.getValue() ) {
if ( notifications == null ) {
notifications = new ArrayList<QueuedNotification>( listenersEntry.getValue().size() );
}
QueuedNotification notification = new QueuedNotification(isUpdate, registeredPaths, listener, filter);
notifications.add(notification);
// parm1: additions, parm2: removals, parm3: updates
// if ( isUpdate ) {
// listener.notifyEntryChange(emptyNotification, emptyNotification, registeredPaths);
// } else {
// listener.notifyEntryChange(emptyNotification, registeredPaths, emptyNotification);
// }
}
}
}
if ( notifications != null ) {
for ( QueuedNotification notification : notifications ) {
notification.fire();
}
}
} | java | private void notifyAllListeners(boolean isUpdate, String filter) {
// Can't reuse the registered paths collection across the loop
// because the listener notification can do processing in a new
// thread. Reusing the registered paths could cause a collision
// between the listener thread with this notification processing
// thread.
// TODO: Should the notification step be separated from the listener detection step?
// That might create large data structures, but would prevent the listeners
// from being locked during a possibly extensive steps of the listeners handling
// their notifications.
// TODO: See the comment, below. The notification step has been separated from the
// listener collection step.
List<QueuedNotification> notifications = null;
synchronized( listenersLock ) {
for ( Map.Entry<String, Collection<ArtifactListenerSelector>> listenersEntry : listeners.entrySet() ) {
List<String> a_registeredPaths = new ArrayList<String>();
collectRegisteredPaths( listenersEntry.getKey(), a_registeredPaths );
if ( a_registeredPaths.isEmpty() ) {
continue;
}
ArtifactNotification registeredPaths =
new DefaultArtifactNotification(rootContainer, a_registeredPaths);
for ( ArtifactListenerSelector listener : listenersEntry.getValue() ) {
if ( notifications == null ) {
notifications = new ArrayList<QueuedNotification>( listenersEntry.getValue().size() );
}
QueuedNotification notification = new QueuedNotification(isUpdate, registeredPaths, listener, filter);
notifications.add(notification);
// parm1: additions, parm2: removals, parm3: updates
// if ( isUpdate ) {
// listener.notifyEntryChange(emptyNotification, emptyNotification, registeredPaths);
// } else {
// listener.notifyEntryChange(emptyNotification, registeredPaths, emptyNotification);
// }
}
}
}
if ( notifications != null ) {
for ( QueuedNotification notification : notifications ) {
notification.fire();
}
}
} | [
"private",
"void",
"notifyAllListeners",
"(",
"boolean",
"isUpdate",
",",
"String",
"filter",
")",
"{",
"// Can't reuse the registered paths collection across the loop",
"// because the listener notification can do processing in a new",
"// thread. Reusing the registered paths could cause a collision",
"// between the listener thread with this notification processing",
"// thread.",
"// TODO: Should the notification step be separated from the listener detection step?",
"// That might create large data structures, but would prevent the listeners",
"// from being locked during a possibly extensive steps of the listeners handling",
"// their notifications.",
"// TODO: See the comment, below. The notification step has been separated from the",
"// listener collection step.",
"List",
"<",
"QueuedNotification",
">",
"notifications",
"=",
"null",
";",
"synchronized",
"(",
"listenersLock",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Collection",
"<",
"ArtifactListenerSelector",
">",
">",
"listenersEntry",
":",
"listeners",
".",
"entrySet",
"(",
")",
")",
"{",
"List",
"<",
"String",
">",
"a_registeredPaths",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"collectRegisteredPaths",
"(",
"listenersEntry",
".",
"getKey",
"(",
")",
",",
"a_registeredPaths",
")",
";",
"if",
"(",
"a_registeredPaths",
".",
"isEmpty",
"(",
")",
")",
"{",
"continue",
";",
"}",
"ArtifactNotification",
"registeredPaths",
"=",
"new",
"DefaultArtifactNotification",
"(",
"rootContainer",
",",
"a_registeredPaths",
")",
";",
"for",
"(",
"ArtifactListenerSelector",
"listener",
":",
"listenersEntry",
".",
"getValue",
"(",
")",
")",
"{",
"if",
"(",
"notifications",
"==",
"null",
")",
"{",
"notifications",
"=",
"new",
"ArrayList",
"<",
"QueuedNotification",
">",
"(",
"listenersEntry",
".",
"getValue",
"(",
")",
".",
"size",
"(",
")",
")",
";",
"}",
"QueuedNotification",
"notification",
"=",
"new",
"QueuedNotification",
"(",
"isUpdate",
",",
"registeredPaths",
",",
"listener",
",",
"filter",
")",
";",
"notifications",
".",
"add",
"(",
"notification",
")",
";",
"// parm1: additions, parm2: removals, parm3: updates",
"// if ( isUpdate ) {",
"// listener.notifyEntryChange(emptyNotification, emptyNotification, registeredPaths);",
"// } else {",
"// listener.notifyEntryChange(emptyNotification, registeredPaths, emptyNotification);",
"// }",
"}",
"}",
"}",
"if",
"(",
"notifications",
"!=",
"null",
")",
"{",
"for",
"(",
"QueuedNotification",
"notification",
":",
"notifications",
")",
"{",
"notification",
".",
"fire",
"(",
")",
";",
"}",
"}",
"}"
] | A notification, which was either an update to the entire zip, or was
the removal of the entire zip file, was received. For each listener
that is registered, collect the paths for that listener and forward
the notification.
The notification which is forwarded to each listener is of the same
type -- update or removal -- as the entire zip notification.
TODO: We *could* try to provide finer notification in case of a whole
zip update. That could be done by comparing the the prior zip
entries with the current zip entries, for example, by comparing
the zip entry lengths, last modified times, and sizes.
@param isUpdate Control parameter: Tell if the notification was an
update of the entire zip file, or a removal of the entire zip file.
@param filter The filter string that allows only those artifact listeners with a matching id to be called to process the artifact event. | [
"A",
"notification",
"which",
"was",
"either",
"an",
"update",
"to",
"the",
"entire",
"zip",
"or",
"was",
"the",
"removal",
"of",
"the",
"entire",
"zip",
"file",
"was",
"received",
".",
"For",
"each",
"listener",
"that",
"is",
"registered",
"collect",
"the",
"paths",
"for",
"that",
"listener",
"and",
"forward",
"the",
"notification",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.artifact.zip/src/com/ibm/ws/artifact/zip/internal/ZipFileArtifactNotifier.java#L788-L840 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.security/src/com/ibm/ws/messaging/security/authentication/actions/MessagingLoginAction.java | MessagingLoginAction.getAuthenticationService | public AuthenticationService getAuthenticationService(SecurityService securityService) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.entry(tc, CLASS_NAME + "getAuthenticationService", securityService);
}
if(_authenticationService == null) {
if (securityService != null)
_authenticationService = securityService
.getAuthenticationService();
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.exit(tc, CLASS_NAME + "getAuthenticationService", _authenticationService);
}
return _authenticationService;
} | java | public AuthenticationService getAuthenticationService(SecurityService securityService) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.entry(tc, CLASS_NAME + "getAuthenticationService", securityService);
}
if(_authenticationService == null) {
if (securityService != null)
_authenticationService = securityService
.getAuthenticationService();
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.exit(tc, CLASS_NAME + "getAuthenticationService", _authenticationService);
}
return _authenticationService;
} | [
"public",
"AuthenticationService",
"getAuthenticationService",
"(",
"SecurityService",
"securityService",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"CLASS_NAME",
"+",
"\"getAuthenticationService\"",
",",
"securityService",
")",
";",
"}",
"if",
"(",
"_authenticationService",
"==",
"null",
")",
"{",
"if",
"(",
"securityService",
"!=",
"null",
")",
"_authenticationService",
"=",
"securityService",
".",
"getAuthenticationService",
"(",
")",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"CLASS_NAME",
"+",
"\"getAuthenticationService\"",
",",
"_authenticationService",
")",
";",
"}",
"return",
"_authenticationService",
";",
"}"
] | Get Authentication Service from the Liberty Security component
It will get the AuthenticationService only if the SecurityService is activated
@param securityService
@return | [
"Get",
"Authentication",
"Service",
"from",
"the",
"Liberty",
"Security",
"component",
"It",
"will",
"get",
"the",
"AuthenticationService",
"only",
"if",
"the",
"SecurityService",
"is",
"activated"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.security/src/com/ibm/ws/messaging/security/authentication/actions/MessagingLoginAction.java#L104-L117 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.security/src/com/ibm/ws/messaging/security/authentication/actions/MessagingLoginAction.java | MessagingLoginAction.login | protected Subject login() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.entry(tc, CLASS_NAME + "login");
}
Subject subject = null;
try {
/*
* Only if we have the AuthenticationService running, we can do
* Authentication. If it is not present we cannot do any
* authentication and hence we have return null, which means
* authentication failed
*/
if (_authenticationService != null) {
subject = _authenticationService.authenticate(MESSAGING_JASS_ENTRY_NAME,
_authenticationData, _partialSubject);
}
} catch (AuthenticationException ae) {
// No FFDC Required. We will throw exception if the subject is Null later
if(TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
SibTr.debug(tc, "EXCEPTION_OCCURED_DURING_AUTHENTICATION_MSE1001");
SibTr.exception(tc, ae);
}
} finally {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.exit(tc, CLASS_NAME + "login");
}
}
return subject;
} | java | protected Subject login() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.entry(tc, CLASS_NAME + "login");
}
Subject subject = null;
try {
/*
* Only if we have the AuthenticationService running, we can do
* Authentication. If it is not present we cannot do any
* authentication and hence we have return null, which means
* authentication failed
*/
if (_authenticationService != null) {
subject = _authenticationService.authenticate(MESSAGING_JASS_ENTRY_NAME,
_authenticationData, _partialSubject);
}
} catch (AuthenticationException ae) {
// No FFDC Required. We will throw exception if the subject is Null later
if(TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
SibTr.debug(tc, "EXCEPTION_OCCURED_DURING_AUTHENTICATION_MSE1001");
SibTr.exception(tc, ae);
}
} finally {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.exit(tc, CLASS_NAME + "login");
}
}
return subject;
} | [
"protected",
"Subject",
"login",
"(",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"CLASS_NAME",
"+",
"\"login\"",
")",
";",
"}",
"Subject",
"subject",
"=",
"null",
";",
"try",
"{",
"/*\n\t\t\t * Only if we have the AuthenticationService running, we can do\n\t\t\t * Authentication. If it is not present we cannot do any\n\t\t\t * authentication and hence we have return null, which means\n\t\t\t * authentication failed\n\t\t\t */",
"if",
"(",
"_authenticationService",
"!=",
"null",
")",
"{",
"subject",
"=",
"_authenticationService",
".",
"authenticate",
"(",
"MESSAGING_JASS_ENTRY_NAME",
",",
"_authenticationData",
",",
"_partialSubject",
")",
";",
"}",
"}",
"catch",
"(",
"AuthenticationException",
"ae",
")",
"{",
"// No FFDC Required. We will throw exception if the subject is Null later",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"SibTr",
".",
"debug",
"(",
"tc",
",",
"\"EXCEPTION_OCCURED_DURING_AUTHENTICATION_MSE1001\"",
")",
";",
"SibTr",
".",
"exception",
"(",
"tc",
",",
"ae",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"CLASS_NAME",
"+",
"\"login\"",
")",
";",
"}",
"}",
"return",
"subject",
";",
"}"
] | The method to authenticate a User
@return
Subject: If the User is authenticated
Null : If User is not authenticated | [
"The",
"method",
"to",
"authenticate",
"a",
"User"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.security/src/com/ibm/ws/messaging/security/authentication/actions/MessagingLoginAction.java#L141-L169 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.comms.server/src/com/ibm/ws/sib/comms/server/CommonServerReceiveListener.java | CommonServerReceiveListener.rejectHandshake | private void rejectHandshake(Conversation conversation, int requestNumber, String rejectedField) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "rejectHandshake",
new Object[] { conversation, requestNumber, rejectedField });
SIConnectionLostException exception = new SIConnectionLostException(
nls.getFormattedMessage("INVALID_PROP_SICO8012", null, null)
);
FFDCFilter.processException(exception,
CLASS_NAME + ".rejectHandshake",
CommsConstants.COMMONSERVERRECEIVELISTENER_HSREJCT_01,
this);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
SibTr.debug(this, tc, "Invalid handshake type received - rejecting field:",
rejectedField);
StaticCATHelper.sendExceptionToClient(exception,
CommsConstants.COMMONSERVERRECEIVELISTENER_HSREJCT_01,
conversation,
requestNumber);
// At this point we really don't want anything more to do with this client - so close him
closeConnection(conversation);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "rejectHandshake");
} | java | private void rejectHandshake(Conversation conversation, int requestNumber, String rejectedField) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "rejectHandshake",
new Object[] { conversation, requestNumber, rejectedField });
SIConnectionLostException exception = new SIConnectionLostException(
nls.getFormattedMessage("INVALID_PROP_SICO8012", null, null)
);
FFDCFilter.processException(exception,
CLASS_NAME + ".rejectHandshake",
CommsConstants.COMMONSERVERRECEIVELISTENER_HSREJCT_01,
this);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
SibTr.debug(this, tc, "Invalid handshake type received - rejecting field:",
rejectedField);
StaticCATHelper.sendExceptionToClient(exception,
CommsConstants.COMMONSERVERRECEIVELISTENER_HSREJCT_01,
conversation,
requestNumber);
// At this point we really don't want anything more to do with this client - so close him
closeConnection(conversation);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "rejectHandshake");
} | [
"private",
"void",
"rejectHandshake",
"(",
"Conversation",
"conversation",
",",
"int",
"requestNumber",
",",
"String",
"rejectedField",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"rejectHandshake\"",
",",
"new",
"Object",
"[",
"]",
"{",
"conversation",
",",
"requestNumber",
",",
"rejectedField",
"}",
")",
";",
"SIConnectionLostException",
"exception",
"=",
"new",
"SIConnectionLostException",
"(",
"nls",
".",
"getFormattedMessage",
"(",
"\"INVALID_PROP_SICO8012\"",
",",
"null",
",",
"null",
")",
")",
";",
"FFDCFilter",
".",
"processException",
"(",
"exception",
",",
"CLASS_NAME",
"+",
"\".rejectHandshake\"",
",",
"CommsConstants",
".",
"COMMONSERVERRECEIVELISTENER_HSREJCT_01",
",",
"this",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"SibTr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"Invalid handshake type received - rejecting field:\"",
",",
"rejectedField",
")",
";",
"StaticCATHelper",
".",
"sendExceptionToClient",
"(",
"exception",
",",
"CommsConstants",
".",
"COMMONSERVERRECEIVELISTENER_HSREJCT_01",
",",
"conversation",
",",
"requestNumber",
")",
";",
"// At this point we really don't want anything more to do with this client - so close him",
"closeConnection",
"(",
"conversation",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"rejectHandshake\"",
")",
";",
"}"
] | This method is used to inform the client that we are rejecting their handshake. Typically
this will never happen unless a third party client is written, or an internal error occurs.
However, we should check for an inproperly formatted handshake and inform the client if
such an error occurs.
@param conversation
@param requestNumber
@param rejectedField A String that indicates the field that was rejected. | [
"This",
"method",
"is",
"used",
"to",
"inform",
"the",
"client",
"that",
"we",
"are",
"rejecting",
"their",
"handshake",
".",
"Typically",
"this",
"will",
"never",
"happen",
"unless",
"a",
"third",
"party",
"client",
"is",
"written",
"or",
"an",
"internal",
"error",
"occurs",
".",
"However",
"we",
"should",
"check",
"for",
"an",
"inproperly",
"formatted",
"handshake",
"and",
"inform",
"the",
"client",
"if",
"such",
"an",
"error",
"occurs",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.comms.server/src/com/ibm/ws/sib/comms/server/CommonServerReceiveListener.java#L768-L796 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.cloudant/src/com/ibm/ws/cloudant/internal/CloudantApplicationListener.java | CloudantApplicationListener.register | void register(CloudantService svc, ConcurrentMap<ClientKey, Object> clients) {
registrations.put(svc, clients);
} | java | void register(CloudantService svc, ConcurrentMap<ClientKey, Object> clients) {
registrations.put(svc, clients);
} | [
"void",
"register",
"(",
"CloudantService",
"svc",
",",
"ConcurrentMap",
"<",
"ClientKey",
",",
"Object",
">",
"clients",
")",
"{",
"registrations",
".",
"put",
"(",
"svc",
",",
"clients",
")",
";",
"}"
] | Lazily registers a CloudantService to have its client cache purged of entries related to a stopped application.
@param svc CloudantService instance. This is used as a HashMap key because the client cache itself is not suitable as a key.
@param clients client cache for the CloudantService. | [
"Lazily",
"registers",
"a",
"CloudantService",
"to",
"have",
"its",
"client",
"cache",
"purged",
"of",
"entries",
"related",
"to",
"a",
"stopped",
"application",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.cloudant/src/com/ibm/ws/cloudant/internal/CloudantApplicationListener.java#L96-L98 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.mdb/src/com/ibm/ws/ejbcontainer/mdb/internal/MessageEndpointFactoryImpl.java | MessageEndpointFactoryImpl.setRRSTransactional | @FFDCIgnore(NoSuchMethodException.class)
private void setRRSTransactional() {
try {
ivRRSTransactional = (Boolean) activationSpec.getClass().getMethod("getRRSTransactional").invoke(activationSpec);
} catch (NoSuchMethodException x) {
ivRRSTransactional = false;
} catch (Exception x) {
ivRRSTransactional = x == null; // always false - avoid a FindBugs warning by using the value of x in some trivial way
}
} | java | @FFDCIgnore(NoSuchMethodException.class)
private void setRRSTransactional() {
try {
ivRRSTransactional = (Boolean) activationSpec.getClass().getMethod("getRRSTransactional").invoke(activationSpec);
} catch (NoSuchMethodException x) {
ivRRSTransactional = false;
} catch (Exception x) {
ivRRSTransactional = x == null; // always false - avoid a FindBugs warning by using the value of x in some trivial way
}
} | [
"@",
"FFDCIgnore",
"(",
"NoSuchMethodException",
".",
"class",
")",
"private",
"void",
"setRRSTransactional",
"(",
")",
"{",
"try",
"{",
"ivRRSTransactional",
"=",
"(",
"Boolean",
")",
"activationSpec",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"\"getRRSTransactional\"",
")",
".",
"invoke",
"(",
"activationSpec",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"x",
")",
"{",
"ivRRSTransactional",
"=",
"false",
";",
"}",
"catch",
"(",
"Exception",
"x",
")",
"{",
"ivRRSTransactional",
"=",
"x",
"==",
"null",
";",
"// always false - avoid a FindBugs warning by using the value of x in some trivial way",
"}",
"}"
] | If an RA wants to enable RRS Transactions, it should return true for the method getRRSTransactional. | [
"If",
"an",
"RA",
"wants",
"to",
"enable",
"RRS",
"Transactions",
"it",
"should",
"return",
"true",
"for",
"the",
"method",
"getRRSTransactional",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.mdb/src/com/ibm/ws/ejbcontainer/mdb/internal/MessageEndpointFactoryImpl.java#L262-L271 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.mdb/src/com/ibm/ws/ejbcontainer/mdb/internal/MessageEndpointFactoryImpl.java | MessageEndpointFactoryImpl.setJCAVersion | @Override
public void setJCAVersion(int majorJCAVer, int minorJCAVer) {
majorJCAVersion = majorJCAVer;
minorJCAVersion = minorJCAVer;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "MessageEndpointFactoryImpl.setJCAVersionJCA: Version " + majorJCAVersion + "." + minorJCAVersion + " is set");
}
} | java | @Override
public void setJCAVersion(int majorJCAVer, int minorJCAVer) {
majorJCAVersion = majorJCAVer;
minorJCAVersion = minorJCAVer;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "MessageEndpointFactoryImpl.setJCAVersionJCA: Version " + majorJCAVersion + "." + minorJCAVersion + " is set");
}
} | [
"@",
"Override",
"public",
"void",
"setJCAVersion",
"(",
"int",
"majorJCAVer",
",",
"int",
"minorJCAVer",
")",
"{",
"majorJCAVersion",
"=",
"majorJCAVer",
";",
"minorJCAVersion",
"=",
"minorJCAVer",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"MessageEndpointFactoryImpl.setJCAVersionJCA: Version \"",
"+",
"majorJCAVersion",
"+",
"\".\"",
"+",
"minorJCAVersion",
"+",
"\" is set\"",
")",
";",
"}",
"}"
] | Indicates what version of JCA specification the RA using
this MessageEndpointFactory requires compliance with.
@see com.ibm.ws.jca.service.WSMessageEndpointFactory#setJCAVersion(int, int) | [
"Indicates",
"what",
"version",
"of",
"JCA",
"specification",
"the",
"RA",
"using",
"this",
"MessageEndpointFactory",
"requires",
"compliance",
"with",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.mdb/src/com/ibm/ws/ejbcontainer/mdb/internal/MessageEndpointFactoryImpl.java#L394-L401 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/EJBMethodInfoStack.java | EJBMethodInfoStack.setup | private void setup(BeanMetaData bmd)
{
if (!ivSetup)
{
int slotSize = bmd.container.getEJBRuntime().getMetaDataSlotSize(MethodMetaData.class);
for (int i = 0; i < capacity; ++i)
{
EJBMethodInfoImpl methodInfo = bmd.createEJBMethodInfoImpl(slotSize);
methodInfo.initializeInstanceData(null, null, null, null, null, false);
elements[i] = methodInfo;
}
ivSetup = true;
}
} | java | private void setup(BeanMetaData bmd)
{
if (!ivSetup)
{
int slotSize = bmd.container.getEJBRuntime().getMetaDataSlotSize(MethodMetaData.class);
for (int i = 0; i < capacity; ++i)
{
EJBMethodInfoImpl methodInfo = bmd.createEJBMethodInfoImpl(slotSize);
methodInfo.initializeInstanceData(null, null, null, null, null, false);
elements[i] = methodInfo;
}
ivSetup = true;
}
} | [
"private",
"void",
"setup",
"(",
"BeanMetaData",
"bmd",
")",
"{",
"if",
"(",
"!",
"ivSetup",
")",
"{",
"int",
"slotSize",
"=",
"bmd",
".",
"container",
".",
"getEJBRuntime",
"(",
")",
".",
"getMetaDataSlotSize",
"(",
"MethodMetaData",
".",
"class",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"capacity",
";",
"++",
"i",
")",
"{",
"EJBMethodInfoImpl",
"methodInfo",
"=",
"bmd",
".",
"createEJBMethodInfoImpl",
"(",
"slotSize",
")",
";",
"methodInfo",
".",
"initializeInstanceData",
"(",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"false",
")",
";",
"elements",
"[",
"i",
"]",
"=",
"methodInfo",
";",
"}",
"ivSetup",
"=",
"true",
";",
"}",
"}"
] | Construct capacity sized stack | [
"Construct",
"capacity",
"sized",
"stack"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/EJBMethodInfoStack.java#L52-L65 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/EJBMethodInfoStack.java | EJBMethodInfoStack.done | public final void done(EJBMethodInfoImpl mi)
{
//d151861
if (orig || (mi == null) || (topOfStack == 0))
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "In orig mode returning:" + " orig: " + orig +
" top: " + topOfStack + " mi: " + mi);
orig = true;
elements = null;//d166651
}
//d151861
else
{
--topOfStack;
if (topOfStack < capacity)
{
//d156621
if (mi != (elements[topOfStack]))
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "EJBMethodInfoStack::done called with wrong " +
"TopOfStack value: " + mi + "!=" + (elements[topOfStack]));
orig = true;
elements = null;//d166651
}
else
elements[topOfStack].initializeInstanceData(null, null, null, // 199625
null, null, false);//d162441
//d156621
}
}
} | java | public final void done(EJBMethodInfoImpl mi)
{
//d151861
if (orig || (mi == null) || (topOfStack == 0))
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "In orig mode returning:" + " orig: " + orig +
" top: " + topOfStack + " mi: " + mi);
orig = true;
elements = null;//d166651
}
//d151861
else
{
--topOfStack;
if (topOfStack < capacity)
{
//d156621
if (mi != (elements[topOfStack]))
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "EJBMethodInfoStack::done called with wrong " +
"TopOfStack value: " + mi + "!=" + (elements[topOfStack]));
orig = true;
elements = null;//d166651
}
else
elements[topOfStack].initializeInstanceData(null, null, null, // 199625
null, null, false);//d162441
//d156621
}
}
} | [
"public",
"final",
"void",
"done",
"(",
"EJBMethodInfoImpl",
"mi",
")",
"{",
"//d151861",
"if",
"(",
"orig",
"||",
"(",
"mi",
"==",
"null",
")",
"||",
"(",
"topOfStack",
"==",
"0",
")",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"In orig mode returning:\"",
"+",
"\" orig: \"",
"+",
"orig",
"+",
"\" top: \"",
"+",
"topOfStack",
"+",
"\" mi: \"",
"+",
"mi",
")",
";",
"orig",
"=",
"true",
";",
"elements",
"=",
"null",
";",
"//d166651",
"}",
"//d151861",
"else",
"{",
"--",
"topOfStack",
";",
"if",
"(",
"topOfStack",
"<",
"capacity",
")",
"{",
"//d156621",
"if",
"(",
"mi",
"!=",
"(",
"elements",
"[",
"topOfStack",
"]",
")",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"EJBMethodInfoStack::done called with wrong \"",
"+",
"\"TopOfStack value: \"",
"+",
"mi",
"+",
"\"!=\"",
"+",
"(",
"elements",
"[",
"topOfStack",
"]",
")",
")",
";",
"orig",
"=",
"true",
";",
"elements",
"=",
"null",
";",
"//d166651",
"}",
"else",
"elements",
"[",
"topOfStack",
"]",
".",
"initializeInstanceData",
"(",
"null",
",",
"null",
",",
"null",
",",
"// 199625",
"null",
",",
"null",
",",
"false",
")",
";",
"//d162441",
"//d156621",
"}",
"}",
"}"
] | Indicate that the caller is finished with the instance that was last obtained. | [
"Indicate",
"that",
"the",
"caller",
"is",
"finished",
"with",
"the",
"instance",
"that",
"was",
"last",
"obtained",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/EJBMethodInfoStack.java#L76-L108 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/EJBMethodInfoStack.java | EJBMethodInfoStack.get | final public EJBMethodInfoImpl get(String methodSignature,
String methodNameOnly,
EJSWrapperBase wrapper,
MethodInterface methodInterface, // d164221
TransactionAttribute txAttr) // 199625
{
EJBMethodInfoImpl retVal = null;
BeanMetaData bmd = wrapper.bmd;
setup(bmd);// delay initting array so we can get slot count
//d151861
if ((topOfStack < 0) || orig)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "EJBMethodInfoStack::get called with neg TopOfStack " +
"or in orig mode:" + topOfStack + " orig: " + orig);
orig = true;
elements = null;//d166651
retVal = bmd.createEJBMethodInfoImpl(bmd.container.getEJBRuntime().getMetaDataSlotSize(MethodMetaData.class));
}//d151861
else
{
if (topOfStack < elements.length)
{
retVal = elements[topOfStack++];
}
else
{
++topOfStack;
retVal = bmd.createEJBMethodInfoImpl(bmd.container.getEJBRuntime().getMetaDataSlotSize(MethodMetaData.class));
}
}
retVal.initializeInstanceData(null, methodNameOnly, bmd, methodInterface, txAttr, false);
return retVal;
} | java | final public EJBMethodInfoImpl get(String methodSignature,
String methodNameOnly,
EJSWrapperBase wrapper,
MethodInterface methodInterface, // d164221
TransactionAttribute txAttr) // 199625
{
EJBMethodInfoImpl retVal = null;
BeanMetaData bmd = wrapper.bmd;
setup(bmd);// delay initting array so we can get slot count
//d151861
if ((topOfStack < 0) || orig)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "EJBMethodInfoStack::get called with neg TopOfStack " +
"or in orig mode:" + topOfStack + " orig: " + orig);
orig = true;
elements = null;//d166651
retVal = bmd.createEJBMethodInfoImpl(bmd.container.getEJBRuntime().getMetaDataSlotSize(MethodMetaData.class));
}//d151861
else
{
if (topOfStack < elements.length)
{
retVal = elements[topOfStack++];
}
else
{
++topOfStack;
retVal = bmd.createEJBMethodInfoImpl(bmd.container.getEJBRuntime().getMetaDataSlotSize(MethodMetaData.class));
}
}
retVal.initializeInstanceData(null, methodNameOnly, bmd, methodInterface, txAttr, false);
return retVal;
} | [
"final",
"public",
"EJBMethodInfoImpl",
"get",
"(",
"String",
"methodSignature",
",",
"String",
"methodNameOnly",
",",
"EJSWrapperBase",
"wrapper",
",",
"MethodInterface",
"methodInterface",
",",
"// d164221",
"TransactionAttribute",
"txAttr",
")",
"// 199625",
"{",
"EJBMethodInfoImpl",
"retVal",
"=",
"null",
";",
"BeanMetaData",
"bmd",
"=",
"wrapper",
".",
"bmd",
";",
"setup",
"(",
"bmd",
")",
";",
"// delay initting array so we can get slot count",
"//d151861",
"if",
"(",
"(",
"topOfStack",
"<",
"0",
")",
"||",
"orig",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"EJBMethodInfoStack::get called with neg TopOfStack \"",
"+",
"\"or in orig mode:\"",
"+",
"topOfStack",
"+",
"\" orig: \"",
"+",
"orig",
")",
";",
"orig",
"=",
"true",
";",
"elements",
"=",
"null",
";",
"//d166651",
"retVal",
"=",
"bmd",
".",
"createEJBMethodInfoImpl",
"(",
"bmd",
".",
"container",
".",
"getEJBRuntime",
"(",
")",
".",
"getMetaDataSlotSize",
"(",
"MethodMetaData",
".",
"class",
")",
")",
";",
"}",
"//d151861",
"else",
"{",
"if",
"(",
"topOfStack",
"<",
"elements",
".",
"length",
")",
"{",
"retVal",
"=",
"elements",
"[",
"topOfStack",
"++",
"]",
";",
"}",
"else",
"{",
"++",
"topOfStack",
";",
"retVal",
"=",
"bmd",
".",
"createEJBMethodInfoImpl",
"(",
"bmd",
".",
"container",
".",
"getEJBRuntime",
"(",
")",
".",
"getMetaDataSlotSize",
"(",
"MethodMetaData",
".",
"class",
")",
")",
";",
"}",
"}",
"retVal",
".",
"initializeInstanceData",
"(",
"null",
",",
"methodNameOnly",
",",
"bmd",
",",
"methodInterface",
",",
"txAttr",
",",
"false",
")",
";",
"return",
"retVal",
";",
"}"
] | Get an instance of EJBMethodInfoImpl.
Either return EJBMethod off the stack or new up a new instance after
stack capacity is exhausted returns EJBMethodInfoImpl | [
"Get",
"an",
"instance",
"of",
"EJBMethodInfoImpl",
".",
"Either",
"return",
"EJBMethod",
"off",
"the",
"stack",
"or",
"new",
"up",
"a",
"new",
"instance",
"after",
"stack",
"capacity",
"is",
"exhausted",
"returns",
"EJBMethodInfoImpl"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/EJBMethodInfoStack.java#L115-L150 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.serialization/src/com/ibm/ws/serialization/internal/SerializationServiceImpl.java | SerializationServiceImpl.loadClass | Class<?> loadClass(String name) throws ClassNotFoundException {
// First, try to find the class by name.
ServiceReference<DeserializationClassProvider> provider = classProviders.getReference(name);
if (provider != null) {
return loadClass(provider, name);
}
// Next, try to find the class by package.
int index = name.lastIndexOf('.');
if (index != -1) {
String pkg = name.substring(0, index);
provider = packageProviders.getReference(pkg);
if (provider != null) {
return loadClass(provider, name);
}
}
return null;
} | java | Class<?> loadClass(String name) throws ClassNotFoundException {
// First, try to find the class by name.
ServiceReference<DeserializationClassProvider> provider = classProviders.getReference(name);
if (provider != null) {
return loadClass(provider, name);
}
// Next, try to find the class by package.
int index = name.lastIndexOf('.');
if (index != -1) {
String pkg = name.substring(0, index);
provider = packageProviders.getReference(pkg);
if (provider != null) {
return loadClass(provider, name);
}
}
return null;
} | [
"Class",
"<",
"?",
">",
"loadClass",
"(",
"String",
"name",
")",
"throws",
"ClassNotFoundException",
"{",
"// First, try to find the class by name.",
"ServiceReference",
"<",
"DeserializationClassProvider",
">",
"provider",
"=",
"classProviders",
".",
"getReference",
"(",
"name",
")",
";",
"if",
"(",
"provider",
"!=",
"null",
")",
"{",
"return",
"loadClass",
"(",
"provider",
",",
"name",
")",
";",
"}",
"// Next, try to find the class by package.",
"int",
"index",
"=",
"name",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
")",
"{",
"String",
"pkg",
"=",
"name",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"provider",
"=",
"packageProviders",
".",
"getReference",
"(",
"pkg",
")",
";",
"if",
"(",
"provider",
"!=",
"null",
")",
"{",
"return",
"loadClass",
"(",
"provider",
",",
"name",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Attempts to resolve a class from registered class providers.
@param name the class name
@return the class, or null if not found
@throws ClassNotFoundException if a class provider claimed to provide a
class or package, but its bundle did not contain the class | [
"Attempts",
"to",
"resolve",
"a",
"class",
"from",
"registered",
"class",
"providers",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.serialization/src/com/ibm/ws/serialization/internal/SerializationServiceImpl.java#L247-L265 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/impl/WSRdbSpiLocalTransactionImpl.java | WSRdbSpiLocalTransactionImpl.begin | public void begin() throws ResourceException {
if (tc.isEntryEnabled())
Tr.entry(this, tc, "begin", ivMC);
// if the MC marked Stale, it means the user requested a purge pool with an immediate option
// so don't allow any work on the mc
if (ivMC._mcStale) {
if (tc.isDebugEnabled())
Tr.debug(this, tc, "MC is stale");
throw new DataStoreAdapterException("INVALID_CONNECTION", AdapterUtil.staleX(), WSRdbSpiLocalTransactionImpl.class);
}
if (dsConfig.get().enableMultithreadedAccessDetection)
ivMC.detectMultithreadedAccess();
if (!ivMC.isTransactional()) { // do nothing if no enlistment
if (tc.isEntryEnabled())
Tr.exit(this, tc, "begin", "no-op. Enlistment disabled");
return;
}
if (tc.isDebugEnabled()) {
String cId = null;
try {
cId = ivMC.mcf.getCorrelator(ivMC);
} catch (SQLException x) {
// will just log the exception here and ignore it since its in trace
Tr.debug(
tc,
"got an exception trying to get the correlator, exception is: ",
x);
}
if (cId != null) {
StringBuffer stbuf = new StringBuffer(200);
stbuf.append("Correlator: DB2, ID: ");
stbuf.append(cId);
stbuf.append(" Transaction : ");
stbuf.append(this);
stbuf.append(" BEGIN");
Tr.debug(this, tc, stbuf.toString());
}
}
ResourceException re;
// Remove synchronization.
re = ivStateManager.isValid(WSStateManager.LT_BEGIN);
if (re == null) {
//Note the MC handles all notification of connection error event and such on setAutoCommit
// also, it sets it only when necessary
try {
if (ivMC.getAutoCommit())
ivMC.setAutoCommit(false);
} catch (SQLException sqle) {
FFDCFilter.processException(
sqle,
currClass.getName() + ".begin",
"126",
this);
throw new DataStoreAdapterException(
"DSA_ERROR",
sqle,
currClass);
}
//Note this exception is not caught - This is because
// 1) it is of type ResourceException so it can be thrown from the method
// 2) if isValid is okay, this should never fail. If isValid is not okay
// an exception is thrown from there
// We already validated the state in this sync block, so just set it.
ivStateManager.transtate = WSStateManager.LOCAL_TRANSACTION_ACTIVE;
} else
{
// state change was not valid
LocalTransactionException local_tran_excep =
new LocalTransactionException(re.getMessage());
DataStoreAdapterException dsae = new DataStoreAdapterException(
"WS_INTERNAL_ERROR",
local_tran_excep,
currClass,
"Cannot start SPI local transaction.",
"",
local_tran_excep.getMessage());
// Use FFDC to log the possible components list.
FFDCFilter.processException(
dsae,
"com.ibm.ws.rsadapter.spi.WSRdbSpiLocalTransactionImpl.begin",
"127",
this,
new Object[] { "Possible components: WebSphere J2C Implementation" });
if (tc.isEntryEnabled())
Tr.exit(this, tc, "begin", "Exception");
throw dsae;
}
if (tc.isEventEnabled())
Tr.event(
tc,
"SpiLocalTransaction started. ManagedConnection state is "
+ ivMC.getTransactionStateAsString());
if (tc.isEntryEnabled())
Tr.exit(this, tc, "begin");
} | java | public void begin() throws ResourceException {
if (tc.isEntryEnabled())
Tr.entry(this, tc, "begin", ivMC);
// if the MC marked Stale, it means the user requested a purge pool with an immediate option
// so don't allow any work on the mc
if (ivMC._mcStale) {
if (tc.isDebugEnabled())
Tr.debug(this, tc, "MC is stale");
throw new DataStoreAdapterException("INVALID_CONNECTION", AdapterUtil.staleX(), WSRdbSpiLocalTransactionImpl.class);
}
if (dsConfig.get().enableMultithreadedAccessDetection)
ivMC.detectMultithreadedAccess();
if (!ivMC.isTransactional()) { // do nothing if no enlistment
if (tc.isEntryEnabled())
Tr.exit(this, tc, "begin", "no-op. Enlistment disabled");
return;
}
if (tc.isDebugEnabled()) {
String cId = null;
try {
cId = ivMC.mcf.getCorrelator(ivMC);
} catch (SQLException x) {
// will just log the exception here and ignore it since its in trace
Tr.debug(
tc,
"got an exception trying to get the correlator, exception is: ",
x);
}
if (cId != null) {
StringBuffer stbuf = new StringBuffer(200);
stbuf.append("Correlator: DB2, ID: ");
stbuf.append(cId);
stbuf.append(" Transaction : ");
stbuf.append(this);
stbuf.append(" BEGIN");
Tr.debug(this, tc, stbuf.toString());
}
}
ResourceException re;
// Remove synchronization.
re = ivStateManager.isValid(WSStateManager.LT_BEGIN);
if (re == null) {
//Note the MC handles all notification of connection error event and such on setAutoCommit
// also, it sets it only when necessary
try {
if (ivMC.getAutoCommit())
ivMC.setAutoCommit(false);
} catch (SQLException sqle) {
FFDCFilter.processException(
sqle,
currClass.getName() + ".begin",
"126",
this);
throw new DataStoreAdapterException(
"DSA_ERROR",
sqle,
currClass);
}
//Note this exception is not caught - This is because
// 1) it is of type ResourceException so it can be thrown from the method
// 2) if isValid is okay, this should never fail. If isValid is not okay
// an exception is thrown from there
// We already validated the state in this sync block, so just set it.
ivStateManager.transtate = WSStateManager.LOCAL_TRANSACTION_ACTIVE;
} else
{
// state change was not valid
LocalTransactionException local_tran_excep =
new LocalTransactionException(re.getMessage());
DataStoreAdapterException dsae = new DataStoreAdapterException(
"WS_INTERNAL_ERROR",
local_tran_excep,
currClass,
"Cannot start SPI local transaction.",
"",
local_tran_excep.getMessage());
// Use FFDC to log the possible components list.
FFDCFilter.processException(
dsae,
"com.ibm.ws.rsadapter.spi.WSRdbSpiLocalTransactionImpl.begin",
"127",
this,
new Object[] { "Possible components: WebSphere J2C Implementation" });
if (tc.isEntryEnabled())
Tr.exit(this, tc, "begin", "Exception");
throw dsae;
}
if (tc.isEventEnabled())
Tr.event(
tc,
"SpiLocalTransaction started. ManagedConnection state is "
+ ivMC.getTransactionStateAsString());
if (tc.isEntryEnabled())
Tr.exit(this, tc, "begin");
} | [
"public",
"void",
"begin",
"(",
")",
"throws",
"ResourceException",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"begin\"",
",",
"ivMC",
")",
";",
"// if the MC marked Stale, it means the user requested a purge pool with an immediate option",
"// so don't allow any work on the mc",
"if",
"(",
"ivMC",
".",
"_mcStale",
")",
"{",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"MC is stale\"",
")",
";",
"throw",
"new",
"DataStoreAdapterException",
"(",
"\"INVALID_CONNECTION\"",
",",
"AdapterUtil",
".",
"staleX",
"(",
")",
",",
"WSRdbSpiLocalTransactionImpl",
".",
"class",
")",
";",
"}",
"if",
"(",
"dsConfig",
".",
"get",
"(",
")",
".",
"enableMultithreadedAccessDetection",
")",
"ivMC",
".",
"detectMultithreadedAccess",
"(",
")",
";",
"if",
"(",
"!",
"ivMC",
".",
"isTransactional",
"(",
")",
")",
"{",
"// do nothing if no enlistment",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"begin\"",
",",
"\"no-op. Enlistment disabled\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"String",
"cId",
"=",
"null",
";",
"try",
"{",
"cId",
"=",
"ivMC",
".",
"mcf",
".",
"getCorrelator",
"(",
"ivMC",
")",
";",
"}",
"catch",
"(",
"SQLException",
"x",
")",
"{",
"// will just log the exception here and ignore it since its in trace",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"got an exception trying to get the correlator, exception is: \"",
",",
"x",
")",
";",
"}",
"if",
"(",
"cId",
"!=",
"null",
")",
"{",
"StringBuffer",
"stbuf",
"=",
"new",
"StringBuffer",
"(",
"200",
")",
";",
"stbuf",
".",
"append",
"(",
"\"Correlator: DB2, ID: \"",
")",
";",
"stbuf",
".",
"append",
"(",
"cId",
")",
";",
"stbuf",
".",
"append",
"(",
"\" Transaction : \"",
")",
";",
"stbuf",
".",
"append",
"(",
"this",
")",
";",
"stbuf",
".",
"append",
"(",
"\" BEGIN\"",
")",
";",
"Tr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"stbuf",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"ResourceException",
"re",
";",
"// Remove synchronization. ",
"re",
"=",
"ivStateManager",
".",
"isValid",
"(",
"WSStateManager",
".",
"LT_BEGIN",
")",
";",
"if",
"(",
"re",
"==",
"null",
")",
"{",
"//Note the MC handles all notification of connection error event and such on setAutoCommit",
"// also, it sets it only when necessary",
"try",
"{",
"if",
"(",
"ivMC",
".",
"getAutoCommit",
"(",
")",
")",
"ivMC",
".",
"setAutoCommit",
"(",
"false",
")",
";",
"}",
"catch",
"(",
"SQLException",
"sqle",
")",
"{",
"FFDCFilter",
".",
"processException",
"(",
"sqle",
",",
"currClass",
".",
"getName",
"(",
")",
"+",
"\".begin\"",
",",
"\"126\"",
",",
"this",
")",
";",
"throw",
"new",
"DataStoreAdapterException",
"(",
"\"DSA_ERROR\"",
",",
"sqle",
",",
"currClass",
")",
";",
"}",
"//Note this exception is not caught - This is because",
"// 1) it is of type ResourceException so it can be thrown from the method",
"// 2) if isValid is okay, this should never fail. If isValid is not okay",
"// an exception is thrown from there",
"// We already validated the state in this sync block, so just set it. ",
"ivStateManager",
".",
"transtate",
"=",
"WSStateManager",
".",
"LOCAL_TRANSACTION_ACTIVE",
";",
"}",
"else",
"{",
"// state change was not valid ",
"LocalTransactionException",
"local_tran_excep",
"=",
"new",
"LocalTransactionException",
"(",
"re",
".",
"getMessage",
"(",
")",
")",
";",
"DataStoreAdapterException",
"dsae",
"=",
"new",
"DataStoreAdapterException",
"(",
"\"WS_INTERNAL_ERROR\"",
",",
"local_tran_excep",
",",
"currClass",
",",
"\"Cannot start SPI local transaction.\"",
",",
"\"\"",
",",
"local_tran_excep",
".",
"getMessage",
"(",
")",
")",
";",
"// Use FFDC to log the possible components list. ",
"FFDCFilter",
".",
"processException",
"(",
"dsae",
",",
"\"com.ibm.ws.rsadapter.spi.WSRdbSpiLocalTransactionImpl.begin\"",
",",
"\"127\"",
",",
"this",
",",
"new",
"Object",
"[",
"]",
"{",
"\"Possible components: WebSphere J2C Implementation\"",
"}",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"begin\"",
",",
"\"Exception\"",
")",
";",
"throw",
"dsae",
";",
"}",
"if",
"(",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"SpiLocalTransaction started. ManagedConnection state is \"",
"+",
"ivMC",
".",
"getTransactionStateAsString",
"(",
")",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"begin\"",
")",
";",
"}"
] | Begin a local transaction
@exception ResourceException - Possible causes of this exception are:
1) a begin is called but there is already a transaction active for this managedConnection
2) the setAutoCommit failed | [
"Begin",
"a",
"local",
"transaction"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/impl/WSRdbSpiLocalTransactionImpl.java#L81-L193 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/impl/WSRdbSpiLocalTransactionImpl.java | WSRdbSpiLocalTransactionImpl.commit | public void commit() throws ResourceException {
if (tc.isEntryEnabled())
Tr.entry(this, tc, "commit", ivMC);
// if the MC marked Stale, it means the user requested a purge pool with an immediate option
// so don't allow any work on the mc
if (ivMC._mcStale) {
if (tc.isDebugEnabled())
Tr.debug(this, tc, "MC is stale");
throw new DataStoreAdapterException("INVALID_CONNECTION", AdapterUtil.staleX(), WSRdbSpiLocalTransactionImpl.class);
}
if (dsConfig.get().enableMultithreadedAccessDetection)
ivMC.detectMultithreadedAccess();
if (!ivMC.isTransactional()) { // do nothing if no enlistment
if (tc.isEntryEnabled())
Tr.exit(this, tc, "commit", "no-op. Enlistment disabled");
return;
}
if (tc.isDebugEnabled()) {
String cId = null;
try {
cId = ivMC.mcf.getCorrelator(ivMC);
} catch (SQLException x) {
// will just log the exception here and ignore it since its in trace
Tr.debug(
tc,
"got an exception trying to get the correlator, exception is: ",
x);
}
if (cId != null) {
StringBuffer stbuf = new StringBuffer(200);
stbuf.append("Correlator: DB2, ID: ");
stbuf.append(cId);
stbuf.append(" Transaction : ");
stbuf.append(this);
stbuf.append(" COMMIT");
Tr.debug(this, tc, stbuf.toString());
}
}
ResourceException re = ivStateManager.isValid(WSStateManager.LT_COMMIT);
if (re == null)
try
{
// If no work was done during the transaction, the autoCommit value may still
// be on. In this case, just no-op, since some drivers like ConnectJDBC 3.1
// don't allow commit/rollback when autoCommit is on.
// here the autocommit is always false, so we can call commit.
ivConnection.commit();
//Note this exception is not caught - This is because
// 1) it is of type ResourceException so it can be thrown from the method
// 2) if isValid is okay, this should never fail. If isValid is not okay
// an exception is thrown from there
// Already validated the state in this sync block, so just set it.
ivStateManager.transtate = WSStateManager.NO_TRANSACTION_ACTIVE;
}
catch (SQLException se) {
FFDCFilter.processException(
se,
"com.ibm.ws.rsadapter.spi.WSRdbSpiLocalTransactionImpl.commit",
"139",
this);
ResourceException x = AdapterUtil.translateSQLException(se, ivMC, true, currClass);
if (tc.isEntryEnabled())
Tr.exit(this, tc, "commit", "Exception");
throw x;
}
else
{
// state change was not valid
LocalTransactionException local_tran_excep =
new LocalTransactionException(re.getMessage());
DataStoreAdapterException ds = new DataStoreAdapterException(
"WS_INTERNAL_ERROR",
local_tran_excep,
currClass,
"Cannot commit SPI local transaction.",
"",
local_tran_excep.getMessage());
if (tc.isEntryEnabled())
Tr.exit(this, tc, "commit", "Exception");
throw ds;
}
// Reset so we can deferred enlist in a future global transaction.
ivMC.wasLazilyEnlistedInGlobalTran = false;
if (tc.isEventEnabled())
Tr.event(
tc,
"SPILocalTransaction committed. ManagedConnection state is "
+ ivMC.getTransactionStateAsString());
if (tc.isEntryEnabled())
Tr.exit(this, tc, "commit");
} | java | public void commit() throws ResourceException {
if (tc.isEntryEnabled())
Tr.entry(this, tc, "commit", ivMC);
// if the MC marked Stale, it means the user requested a purge pool with an immediate option
// so don't allow any work on the mc
if (ivMC._mcStale) {
if (tc.isDebugEnabled())
Tr.debug(this, tc, "MC is stale");
throw new DataStoreAdapterException("INVALID_CONNECTION", AdapterUtil.staleX(), WSRdbSpiLocalTransactionImpl.class);
}
if (dsConfig.get().enableMultithreadedAccessDetection)
ivMC.detectMultithreadedAccess();
if (!ivMC.isTransactional()) { // do nothing if no enlistment
if (tc.isEntryEnabled())
Tr.exit(this, tc, "commit", "no-op. Enlistment disabled");
return;
}
if (tc.isDebugEnabled()) {
String cId = null;
try {
cId = ivMC.mcf.getCorrelator(ivMC);
} catch (SQLException x) {
// will just log the exception here and ignore it since its in trace
Tr.debug(
tc,
"got an exception trying to get the correlator, exception is: ",
x);
}
if (cId != null) {
StringBuffer stbuf = new StringBuffer(200);
stbuf.append("Correlator: DB2, ID: ");
stbuf.append(cId);
stbuf.append(" Transaction : ");
stbuf.append(this);
stbuf.append(" COMMIT");
Tr.debug(this, tc, stbuf.toString());
}
}
ResourceException re = ivStateManager.isValid(WSStateManager.LT_COMMIT);
if (re == null)
try
{
// If no work was done during the transaction, the autoCommit value may still
// be on. In this case, just no-op, since some drivers like ConnectJDBC 3.1
// don't allow commit/rollback when autoCommit is on.
// here the autocommit is always false, so we can call commit.
ivConnection.commit();
//Note this exception is not caught - This is because
// 1) it is of type ResourceException so it can be thrown from the method
// 2) if isValid is okay, this should never fail. If isValid is not okay
// an exception is thrown from there
// Already validated the state in this sync block, so just set it.
ivStateManager.transtate = WSStateManager.NO_TRANSACTION_ACTIVE;
}
catch (SQLException se) {
FFDCFilter.processException(
se,
"com.ibm.ws.rsadapter.spi.WSRdbSpiLocalTransactionImpl.commit",
"139",
this);
ResourceException x = AdapterUtil.translateSQLException(se, ivMC, true, currClass);
if (tc.isEntryEnabled())
Tr.exit(this, tc, "commit", "Exception");
throw x;
}
else
{
// state change was not valid
LocalTransactionException local_tran_excep =
new LocalTransactionException(re.getMessage());
DataStoreAdapterException ds = new DataStoreAdapterException(
"WS_INTERNAL_ERROR",
local_tran_excep,
currClass,
"Cannot commit SPI local transaction.",
"",
local_tran_excep.getMessage());
if (tc.isEntryEnabled())
Tr.exit(this, tc, "commit", "Exception");
throw ds;
}
// Reset so we can deferred enlist in a future global transaction.
ivMC.wasLazilyEnlistedInGlobalTran = false;
if (tc.isEventEnabled())
Tr.event(
tc,
"SPILocalTransaction committed. ManagedConnection state is "
+ ivMC.getTransactionStateAsString());
if (tc.isEntryEnabled())
Tr.exit(this, tc, "commit");
} | [
"public",
"void",
"commit",
"(",
")",
"throws",
"ResourceException",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"commit\"",
",",
"ivMC",
")",
";",
"// if the MC marked Stale, it means the user requested a purge pool with an immediate option",
"// so don't allow any work on the mc",
"if",
"(",
"ivMC",
".",
"_mcStale",
")",
"{",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"MC is stale\"",
")",
";",
"throw",
"new",
"DataStoreAdapterException",
"(",
"\"INVALID_CONNECTION\"",
",",
"AdapterUtil",
".",
"staleX",
"(",
")",
",",
"WSRdbSpiLocalTransactionImpl",
".",
"class",
")",
";",
"}",
"if",
"(",
"dsConfig",
".",
"get",
"(",
")",
".",
"enableMultithreadedAccessDetection",
")",
"ivMC",
".",
"detectMultithreadedAccess",
"(",
")",
";",
"if",
"(",
"!",
"ivMC",
".",
"isTransactional",
"(",
")",
")",
"{",
"// do nothing if no enlistment",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"commit\"",
",",
"\"no-op. Enlistment disabled\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"String",
"cId",
"=",
"null",
";",
"try",
"{",
"cId",
"=",
"ivMC",
".",
"mcf",
".",
"getCorrelator",
"(",
"ivMC",
")",
";",
"}",
"catch",
"(",
"SQLException",
"x",
")",
"{",
"// will just log the exception here and ignore it since its in trace",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"got an exception trying to get the correlator, exception is: \"",
",",
"x",
")",
";",
"}",
"if",
"(",
"cId",
"!=",
"null",
")",
"{",
"StringBuffer",
"stbuf",
"=",
"new",
"StringBuffer",
"(",
"200",
")",
";",
"stbuf",
".",
"append",
"(",
"\"Correlator: DB2, ID: \"",
")",
";",
"stbuf",
".",
"append",
"(",
"cId",
")",
";",
"stbuf",
".",
"append",
"(",
"\" Transaction : \"",
")",
";",
"stbuf",
".",
"append",
"(",
"this",
")",
";",
"stbuf",
".",
"append",
"(",
"\" COMMIT\"",
")",
";",
"Tr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"stbuf",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"ResourceException",
"re",
"=",
"ivStateManager",
".",
"isValid",
"(",
"WSStateManager",
".",
"LT_COMMIT",
")",
";",
"if",
"(",
"re",
"==",
"null",
")",
"try",
"{",
"// If no work was done during the transaction, the autoCommit value may still",
"// be on. In this case, just no-op, since some drivers like ConnectJDBC 3.1",
"// don't allow commit/rollback when autoCommit is on. ",
"// here the autocommit is always false, so we can call commit.",
"ivConnection",
".",
"commit",
"(",
")",
";",
"//Note this exception is not caught - This is because",
"// 1) it is of type ResourceException so it can be thrown from the method",
"// 2) if isValid is okay, this should never fail. If isValid is not okay",
"// an exception is thrown from there",
"// Already validated the state in this sync block, so just set it. ",
"ivStateManager",
".",
"transtate",
"=",
"WSStateManager",
".",
"NO_TRANSACTION_ACTIVE",
";",
"}",
"catch",
"(",
"SQLException",
"se",
")",
"{",
"FFDCFilter",
".",
"processException",
"(",
"se",
",",
"\"com.ibm.ws.rsadapter.spi.WSRdbSpiLocalTransactionImpl.commit\"",
",",
"\"139\"",
",",
"this",
")",
";",
"ResourceException",
"x",
"=",
"AdapterUtil",
".",
"translateSQLException",
"(",
"se",
",",
"ivMC",
",",
"true",
",",
"currClass",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"commit\"",
",",
"\"Exception\"",
")",
";",
"throw",
"x",
";",
"}",
"else",
"{",
"// state change was not valid ",
"LocalTransactionException",
"local_tran_excep",
"=",
"new",
"LocalTransactionException",
"(",
"re",
".",
"getMessage",
"(",
")",
")",
";",
"DataStoreAdapterException",
"ds",
"=",
"new",
"DataStoreAdapterException",
"(",
"\"WS_INTERNAL_ERROR\"",
",",
"local_tran_excep",
",",
"currClass",
",",
"\"Cannot commit SPI local transaction.\"",
",",
"\"\"",
",",
"local_tran_excep",
".",
"getMessage",
"(",
")",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"commit\"",
",",
"\"Exception\"",
")",
";",
"throw",
"ds",
";",
"}",
"// Reset so we can deferred enlist in a future global transaction. ",
"ivMC",
".",
"wasLazilyEnlistedInGlobalTran",
"=",
"false",
";",
"if",
"(",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"SPILocalTransaction committed. ManagedConnection state is \"",
"+",
"ivMC",
".",
"getTransactionStateAsString",
"(",
")",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"commit\"",
")",
";",
"}"
] | Commit a local transaction
@exception ResourceException - Possible causes for this exception are:
1) if there is no transaction active that can be committed
2) commit was called from an invalid transaction state | [
"Commit",
"a",
"local",
"transaction"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/impl/WSRdbSpiLocalTransactionImpl.java#L202-L306 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/impl/WSRdbSpiLocalTransactionImpl.java | WSRdbSpiLocalTransactionImpl.rollback | public void rollback() throws ResourceException {
if (tc.isEntryEnabled())
Tr.entry(this, tc, "rollback", ivMC);
// if the MC marked Stale, it means the user requested a purge pool with an immediate option
// so don't allow any work on the mc
if (ivMC._mcStale) {
if (tc.isDebugEnabled())
Tr.debug(this, tc, "MC is stale");
throw new DataStoreAdapterException("INVALID_CONNECTION", AdapterUtil.staleX(), WSRdbSpiLocalTransactionImpl.class);
}
if (!ivMC.isTransactional()) { // do nothing if no enlistment
if (tc.isEntryEnabled())
Tr.exit(this, tc, "rollback", "no-op. Enlistment disabled");
return;
}
ResourceException re;
if (tc.isDebugEnabled()) {
String cId = null;
try {
cId = ivMC.mcf.getCorrelator(ivMC);
} catch (SQLException x) {
// will just log the exception here and ignore it since its in trace
Tr.debug(
tc,
"got an exception trying to get the correlator, exception is: ",
x);
}
if (cId != null) {
StringBuffer stbuf = new StringBuffer(200);
stbuf.append("Correlator: DB2, ID: ");
stbuf.append(cId);
stbuf.append(" Transaction : ");
stbuf.append(this);
stbuf.append("ROLLBACK");
Tr.debug(this, tc, stbuf.toString());
}
}
re = ivStateManager.isValid(WSStateManager.LT_ROLLBACK);
if (re == null)
try
{
// If no work was done during the transaction, the autoCommit value may still
// be on. In this case, just no-op, since some drivers like ConnectJDBC 3.1
// don't allow commit/rollback when autoCommit is on.
// here the autocommit is always false, so we can call commit.
ivConnection.rollback();
//Note this exception is not caught - This is because
// 1) it is of type ResourceException so it can be thrown from the method
// 2) if isValid is okay, this should never fail. If isValid is not okay
// an exception is thrown from there
// Already validated the state in this sync block, so just set it.
ivStateManager.transtate = WSStateManager.NO_TRANSACTION_ACTIVE;
}
catch (SQLException se) {
if (!ivMC.isAborted())
FFDCFilter.processException(se, getClass().getName(), "192", this);
ResourceException resX = AdapterUtil.translateSQLException(se, ivMC, true, currClass);
if (tc.isEntryEnabled())
Tr.exit(this, tc, "rollback", "Exception");
throw resX;
}
else
{
// state change was not valid
LocalTransactionException local_tran_excep =
new LocalTransactionException(re.getMessage());
DataStoreAdapterException dsae = new DataStoreAdapterException(
"WS_INTERNAL_ERROR",
local_tran_excep,
currClass,
"Cannot rollback SPI local transaction.",
"",
local_tran_excep.getMessage());
// Use FFDC to log the possible components list.
FFDCFilter.processException(
dsae,
"com.ibm.ws.rsadapter.spi.WSRdbSpiLocalTransactionImpl.rollback",
"291",
this,
new Object[] { " Possible components: WebSphere J2C Implementation" });
if (tc.isEntryEnabled())
Tr.exit(this, tc, "rollback", "Exception");
throw dsae;
}
// Reset so we can deferred enlist in a future global transaction.
ivMC.wasLazilyEnlistedInGlobalTran = false;
if (tc.isEventEnabled())
Tr.event(
tc,
"SpiLocalTransaction rolled back. ManagedConnection state is "
+ ivMC.getTransactionStateAsString());
if (tc.isEntryEnabled())
Tr.exit(this, tc, "rollback");
} | java | public void rollback() throws ResourceException {
if (tc.isEntryEnabled())
Tr.entry(this, tc, "rollback", ivMC);
// if the MC marked Stale, it means the user requested a purge pool with an immediate option
// so don't allow any work on the mc
if (ivMC._mcStale) {
if (tc.isDebugEnabled())
Tr.debug(this, tc, "MC is stale");
throw new DataStoreAdapterException("INVALID_CONNECTION", AdapterUtil.staleX(), WSRdbSpiLocalTransactionImpl.class);
}
if (!ivMC.isTransactional()) { // do nothing if no enlistment
if (tc.isEntryEnabled())
Tr.exit(this, tc, "rollback", "no-op. Enlistment disabled");
return;
}
ResourceException re;
if (tc.isDebugEnabled()) {
String cId = null;
try {
cId = ivMC.mcf.getCorrelator(ivMC);
} catch (SQLException x) {
// will just log the exception here and ignore it since its in trace
Tr.debug(
tc,
"got an exception trying to get the correlator, exception is: ",
x);
}
if (cId != null) {
StringBuffer stbuf = new StringBuffer(200);
stbuf.append("Correlator: DB2, ID: ");
stbuf.append(cId);
stbuf.append(" Transaction : ");
stbuf.append(this);
stbuf.append("ROLLBACK");
Tr.debug(this, tc, stbuf.toString());
}
}
re = ivStateManager.isValid(WSStateManager.LT_ROLLBACK);
if (re == null)
try
{
// If no work was done during the transaction, the autoCommit value may still
// be on. In this case, just no-op, since some drivers like ConnectJDBC 3.1
// don't allow commit/rollback when autoCommit is on.
// here the autocommit is always false, so we can call commit.
ivConnection.rollback();
//Note this exception is not caught - This is because
// 1) it is of type ResourceException so it can be thrown from the method
// 2) if isValid is okay, this should never fail. If isValid is not okay
// an exception is thrown from there
// Already validated the state in this sync block, so just set it.
ivStateManager.transtate = WSStateManager.NO_TRANSACTION_ACTIVE;
}
catch (SQLException se) {
if (!ivMC.isAborted())
FFDCFilter.processException(se, getClass().getName(), "192", this);
ResourceException resX = AdapterUtil.translateSQLException(se, ivMC, true, currClass);
if (tc.isEntryEnabled())
Tr.exit(this, tc, "rollback", "Exception");
throw resX;
}
else
{
// state change was not valid
LocalTransactionException local_tran_excep =
new LocalTransactionException(re.getMessage());
DataStoreAdapterException dsae = new DataStoreAdapterException(
"WS_INTERNAL_ERROR",
local_tran_excep,
currClass,
"Cannot rollback SPI local transaction.",
"",
local_tran_excep.getMessage());
// Use FFDC to log the possible components list.
FFDCFilter.processException(
dsae,
"com.ibm.ws.rsadapter.spi.WSRdbSpiLocalTransactionImpl.rollback",
"291",
this,
new Object[] { " Possible components: WebSphere J2C Implementation" });
if (tc.isEntryEnabled())
Tr.exit(this, tc, "rollback", "Exception");
throw dsae;
}
// Reset so we can deferred enlist in a future global transaction.
ivMC.wasLazilyEnlistedInGlobalTran = false;
if (tc.isEventEnabled())
Tr.event(
tc,
"SpiLocalTransaction rolled back. ManagedConnection state is "
+ ivMC.getTransactionStateAsString());
if (tc.isEntryEnabled())
Tr.exit(this, tc, "rollback");
} | [
"public",
"void",
"rollback",
"(",
")",
"throws",
"ResourceException",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"rollback\"",
",",
"ivMC",
")",
";",
"// if the MC marked Stale, it means the user requested a purge pool with an immediate option",
"// so don't allow any work on the mc",
"if",
"(",
"ivMC",
".",
"_mcStale",
")",
"{",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"MC is stale\"",
")",
";",
"throw",
"new",
"DataStoreAdapterException",
"(",
"\"INVALID_CONNECTION\"",
",",
"AdapterUtil",
".",
"staleX",
"(",
")",
",",
"WSRdbSpiLocalTransactionImpl",
".",
"class",
")",
";",
"}",
"if",
"(",
"!",
"ivMC",
".",
"isTransactional",
"(",
")",
")",
"{",
"// do nothing if no enlistment",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"rollback\"",
",",
"\"no-op. Enlistment disabled\"",
")",
";",
"return",
";",
"}",
"ResourceException",
"re",
";",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"String",
"cId",
"=",
"null",
";",
"try",
"{",
"cId",
"=",
"ivMC",
".",
"mcf",
".",
"getCorrelator",
"(",
"ivMC",
")",
";",
"}",
"catch",
"(",
"SQLException",
"x",
")",
"{",
"// will just log the exception here and ignore it since its in trace",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"got an exception trying to get the correlator, exception is: \"",
",",
"x",
")",
";",
"}",
"if",
"(",
"cId",
"!=",
"null",
")",
"{",
"StringBuffer",
"stbuf",
"=",
"new",
"StringBuffer",
"(",
"200",
")",
";",
"stbuf",
".",
"append",
"(",
"\"Correlator: DB2, ID: \"",
")",
";",
"stbuf",
".",
"append",
"(",
"cId",
")",
";",
"stbuf",
".",
"append",
"(",
"\" Transaction : \"",
")",
";",
"stbuf",
".",
"append",
"(",
"this",
")",
";",
"stbuf",
".",
"append",
"(",
"\"ROLLBACK\"",
")",
";",
"Tr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"stbuf",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"re",
"=",
"ivStateManager",
".",
"isValid",
"(",
"WSStateManager",
".",
"LT_ROLLBACK",
")",
";",
"if",
"(",
"re",
"==",
"null",
")",
"try",
"{",
"// If no work was done during the transaction, the autoCommit value may still",
"// be on. In this case, just no-op, since some drivers like ConnectJDBC 3.1",
"// don't allow commit/rollback when autoCommit is on. ",
"// here the autocommit is always false, so we can call commit.",
"ivConnection",
".",
"rollback",
"(",
")",
";",
"//Note this exception is not caught - This is because",
"// 1) it is of type ResourceException so it can be thrown from the method",
"// 2) if isValid is okay, this should never fail. If isValid is not okay",
"// an exception is thrown from there",
"// Already validated the state in this sync block, so just set it. ",
"ivStateManager",
".",
"transtate",
"=",
"WSStateManager",
".",
"NO_TRANSACTION_ACTIVE",
";",
"}",
"catch",
"(",
"SQLException",
"se",
")",
"{",
"if",
"(",
"!",
"ivMC",
".",
"isAborted",
"(",
")",
")",
"FFDCFilter",
".",
"processException",
"(",
"se",
",",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
",",
"\"192\"",
",",
"this",
")",
";",
"ResourceException",
"resX",
"=",
"AdapterUtil",
".",
"translateSQLException",
"(",
"se",
",",
"ivMC",
",",
"true",
",",
"currClass",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"rollback\"",
",",
"\"Exception\"",
")",
";",
"throw",
"resX",
";",
"}",
"else",
"{",
"// state change was not valid",
"LocalTransactionException",
"local_tran_excep",
"=",
"new",
"LocalTransactionException",
"(",
"re",
".",
"getMessage",
"(",
")",
")",
";",
"DataStoreAdapterException",
"dsae",
"=",
"new",
"DataStoreAdapterException",
"(",
"\"WS_INTERNAL_ERROR\"",
",",
"local_tran_excep",
",",
"currClass",
",",
"\"Cannot rollback SPI local transaction.\"",
",",
"\"\"",
",",
"local_tran_excep",
".",
"getMessage",
"(",
")",
")",
";",
"// Use FFDC to log the possible components list. ",
"FFDCFilter",
".",
"processException",
"(",
"dsae",
",",
"\"com.ibm.ws.rsadapter.spi.WSRdbSpiLocalTransactionImpl.rollback\"",
",",
"\"291\"",
",",
"this",
",",
"new",
"Object",
"[",
"]",
"{",
"\" Possible components: WebSphere J2C Implementation\"",
"}",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"rollback\"",
",",
"\"Exception\"",
")",
";",
"throw",
"dsae",
";",
"}",
"// Reset so we can deferred enlist in a future global transaction. ",
"ivMC",
".",
"wasLazilyEnlistedInGlobalTran",
"=",
"false",
";",
"if",
"(",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"SpiLocalTransaction rolled back. ManagedConnection state is \"",
"+",
"ivMC",
".",
"getTransactionStateAsString",
"(",
")",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"rollback\"",
")",
";",
"}"
] | Rollback a local transaction
@exception ResourceException - Possible causes for this exception are:
1) if there is no transaction active that can be rolledback
2) rollback was called from an invalid transaction state | [
"Rollback",
"a",
"local",
"transaction"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/impl/WSRdbSpiLocalTransactionImpl.java#L338-L448 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsJmsObjectMessageImpl.java | JsJmsObjectMessageImpl.serializeRealObject | private void serializeRealObject() throws ObjectFailedToSerializeException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "serializeRealObject");
if (hasRealObject) {
// If the realObject isn't null, we need to serialize it & set it into the message
if (realObject != null) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
// Write the real object into a byte array
oos.writeObject(realObject);
// Store the bytes in the payload
getPayload().setField(JmsObjectBodyAccess.BODY_DATA_VALUE, baos.toByteArray());
// Set the flag, create a SoftReference to the Object & null out the strong reference
// so the object can be GCd if necessary
hasSerializedRealObject = true;
softRefToRealObject = new SoftReference<Serializable>(realObject);
realObject = null;
}
catch (IOException ioe) {
FFDCFilter.processException(ioe, "com.ibm.ws.sib.mfp.impl.JsJmsObjectMessageImpl.serializeRealObject", "296");
// Wrapper the exception, giving the object's class name, and throw.
String objectClassName = realObject.getClass().getName();
throw new ObjectFailedToSerializeException(ioe
, objectClassName);
}
}
// If the realObject is null, we just set the field in the message & can now claim to have serialized it.
else {
// Real object is null
getPayload().setField(JmsObjectBodyAccess.BODY_DATA_VALUE, null);
// We have not actually serialized anything, but the object data is in the payload
hasSerializedRealObject = true;
}
}
// Any length calculation will need to be redone as the message now 'owns' the payload value
clearCachedLengths();
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "serializeRealObject");
} | java | private void serializeRealObject() throws ObjectFailedToSerializeException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "serializeRealObject");
if (hasRealObject) {
// If the realObject isn't null, we need to serialize it & set it into the message
if (realObject != null) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
// Write the real object into a byte array
oos.writeObject(realObject);
// Store the bytes in the payload
getPayload().setField(JmsObjectBodyAccess.BODY_DATA_VALUE, baos.toByteArray());
// Set the flag, create a SoftReference to the Object & null out the strong reference
// so the object can be GCd if necessary
hasSerializedRealObject = true;
softRefToRealObject = new SoftReference<Serializable>(realObject);
realObject = null;
}
catch (IOException ioe) {
FFDCFilter.processException(ioe, "com.ibm.ws.sib.mfp.impl.JsJmsObjectMessageImpl.serializeRealObject", "296");
// Wrapper the exception, giving the object's class name, and throw.
String objectClassName = realObject.getClass().getName();
throw new ObjectFailedToSerializeException(ioe
, objectClassName);
}
}
// If the realObject is null, we just set the field in the message & can now claim to have serialized it.
else {
// Real object is null
getPayload().setField(JmsObjectBodyAccess.BODY_DATA_VALUE, null);
// We have not actually serialized anything, but the object data is in the payload
hasSerializedRealObject = true;
}
}
// Any length calculation will need to be redone as the message now 'owns' the payload value
clearCachedLengths();
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "serializeRealObject");
} | [
"private",
"void",
"serializeRealObject",
"(",
")",
"throws",
"ObjectFailedToSerializeException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"serializeRealObject\"",
")",
";",
"if",
"(",
"hasRealObject",
")",
"{",
"// If the realObject isn't null, we need to serialize it & set it into the message",
"if",
"(",
"realObject",
"!=",
"null",
")",
"{",
"try",
"{",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ObjectOutputStream",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"baos",
")",
";",
"// Write the real object into a byte array",
"oos",
".",
"writeObject",
"(",
"realObject",
")",
";",
"// Store the bytes in the payload",
"getPayload",
"(",
")",
".",
"setField",
"(",
"JmsObjectBodyAccess",
".",
"BODY_DATA_VALUE",
",",
"baos",
".",
"toByteArray",
"(",
")",
")",
";",
"// Set the flag, create a SoftReference to the Object & null out the strong reference",
"// so the object can be GCd if necessary",
"hasSerializedRealObject",
"=",
"true",
";",
"softRefToRealObject",
"=",
"new",
"SoftReference",
"<",
"Serializable",
">",
"(",
"realObject",
")",
";",
"realObject",
"=",
"null",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"FFDCFilter",
".",
"processException",
"(",
"ioe",
",",
"\"com.ibm.ws.sib.mfp.impl.JsJmsObjectMessageImpl.serializeRealObject\"",
",",
"\"296\"",
")",
";",
"// Wrapper the exception, giving the object's class name, and throw.",
"String",
"objectClassName",
"=",
"realObject",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"throw",
"new",
"ObjectFailedToSerializeException",
"(",
"ioe",
",",
"objectClassName",
")",
";",
"}",
"}",
"// If the realObject is null, we just set the field in the message & can now claim to have serialized it.",
"else",
"{",
"// Real object is null",
"getPayload",
"(",
")",
".",
"setField",
"(",
"JmsObjectBodyAccess",
".",
"BODY_DATA_VALUE",
",",
"null",
")",
";",
"// We have not actually serialized anything, but the object data is in the payload",
"hasSerializedRealObject",
"=",
"true",
";",
"}",
"}",
"// Any length calculation will need to be redone as the message now 'owns' the payload value",
"clearCachedLengths",
"(",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"serializeRealObject\"",
")",
";",
"}"
] | Private method to serialize the 'real' object into the payload.
This method is only called if we have a 'real' object AND it has not already been serialized
Note that this doesn't preclude realObject being null, as null may be the real value
set using setRealObject().
@exception ObjectFailedToSerializeException Serialization of the object failed | [
"Private",
"method",
"to",
"serialize",
"the",
"real",
"object",
"into",
"the",
"payload",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsJmsObjectMessageImpl.java#L373-L419 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsJmsObjectMessageImpl.java | JsJmsObjectMessageImpl.deserializeToRealObject | private Serializable deserializeToRealObject() throws IOException, ClassNotFoundException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "deserializeToRealObject");
Serializable obj = null;
ObjectInputStream ois = null;
byte[] bytes = getDataFromPayload();
if (bytes != null) {
try {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
// Get the classloader, which may be the standard classloader or may be an application
// classloader provided by WebSphere
ClassLoader cl = AccessController.doPrivileged(
new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
return Thread.currentThread().getContextClassLoader();
}
});
ois = new DeserializationObjectInputStream(bais, cl);
// Deserialize the object and set the local variables appropriately
obj = (Serializable) ois.readObject();
hasRealObject = true;
hasSerializedRealObject = true;
softRefToRealObject = new SoftReference<Serializable>(obj);
} catch (IOException ioe) {
FFDCFilter.processException(ioe, "com.ibm.ws.sib.mfp.impl.JsJmsObjectMessageImpl.deserializeToRealObject", "340");
throw ioe;
} catch (ClassNotFoundException cnfe) {
FFDCFilter.processException(cnfe, "com.ibm.ws.sib.mfp.impl.JsJmsObjectMessageImpl.deserializeToRealObject", "345");
throw cnfe;
} finally {
try {
if (ois != null) {
ois.close();
}
} catch (IOException ex) {
// No FFDC code needed
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
SibTr.debug(this, tc, "Exception closing the ObjectInputStream", ex);
}
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "deserializeToRealObject", (obj == null ? "null" : obj.getClass()));
return obj;
} | java | private Serializable deserializeToRealObject() throws IOException, ClassNotFoundException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "deserializeToRealObject");
Serializable obj = null;
ObjectInputStream ois = null;
byte[] bytes = getDataFromPayload();
if (bytes != null) {
try {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
// Get the classloader, which may be the standard classloader or may be an application
// classloader provided by WebSphere
ClassLoader cl = AccessController.doPrivileged(
new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
return Thread.currentThread().getContextClassLoader();
}
});
ois = new DeserializationObjectInputStream(bais, cl);
// Deserialize the object and set the local variables appropriately
obj = (Serializable) ois.readObject();
hasRealObject = true;
hasSerializedRealObject = true;
softRefToRealObject = new SoftReference<Serializable>(obj);
} catch (IOException ioe) {
FFDCFilter.processException(ioe, "com.ibm.ws.sib.mfp.impl.JsJmsObjectMessageImpl.deserializeToRealObject", "340");
throw ioe;
} catch (ClassNotFoundException cnfe) {
FFDCFilter.processException(cnfe, "com.ibm.ws.sib.mfp.impl.JsJmsObjectMessageImpl.deserializeToRealObject", "345");
throw cnfe;
} finally {
try {
if (ois != null) {
ois.close();
}
} catch (IOException ex) {
// No FFDC code needed
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
SibTr.debug(this, tc, "Exception closing the ObjectInputStream", ex);
}
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "deserializeToRealObject", (obj == null ? "null" : obj.getClass()));
return obj;
} | [
"private",
"Serializable",
"deserializeToRealObject",
"(",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"deserializeToRealObject\"",
")",
";",
"Serializable",
"obj",
"=",
"null",
";",
"ObjectInputStream",
"ois",
"=",
"null",
";",
"byte",
"[",
"]",
"bytes",
"=",
"getDataFromPayload",
"(",
")",
";",
"if",
"(",
"bytes",
"!=",
"null",
")",
"{",
"try",
"{",
"ByteArrayInputStream",
"bais",
"=",
"new",
"ByteArrayInputStream",
"(",
"bytes",
")",
";",
"// Get the classloader, which may be the standard classloader or may be an application",
"// classloader provided by WebSphere",
"ClassLoader",
"cl",
"=",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedAction",
"<",
"ClassLoader",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ClassLoader",
"run",
"(",
")",
"{",
"return",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"}",
"}",
")",
";",
"ois",
"=",
"new",
"DeserializationObjectInputStream",
"(",
"bais",
",",
"cl",
")",
";",
"// Deserialize the object and set the local variables appropriately",
"obj",
"=",
"(",
"Serializable",
")",
"ois",
".",
"readObject",
"(",
")",
";",
"hasRealObject",
"=",
"true",
";",
"hasSerializedRealObject",
"=",
"true",
";",
"softRefToRealObject",
"=",
"new",
"SoftReference",
"<",
"Serializable",
">",
"(",
"obj",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"FFDCFilter",
".",
"processException",
"(",
"ioe",
",",
"\"com.ibm.ws.sib.mfp.impl.JsJmsObjectMessageImpl.deserializeToRealObject\"",
",",
"\"340\"",
")",
";",
"throw",
"ioe",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"cnfe",
")",
"{",
"FFDCFilter",
".",
"processException",
"(",
"cnfe",
",",
"\"com.ibm.ws.sib.mfp.impl.JsJmsObjectMessageImpl.deserializeToRealObject\"",
",",
"\"345\"",
")",
";",
"throw",
"cnfe",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"ois",
"!=",
"null",
")",
"{",
"ois",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"// No FFDC code needed",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"SibTr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"Exception closing the ObjectInputStream\"",
",",
"ex",
")",
";",
"}",
"}",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"deserializeToRealObject\"",
",",
"(",
"obj",
"==",
"null",
"?",
"\"null\"",
":",
"obj",
".",
"getClass",
"(",
")",
")",
")",
";",
"return",
"obj",
";",
"}"
] | Private method to deserialize the 'real' object from the payload.
The deserialized object is returned by the method & stored in a SoftReference for
potential future use. A SoftReference is used because we still have the serialized
obejct in the message itself, and, if the object is large, holding both forms
could cause us to go short on heap.
Note this method is only called if we don't already have a realObject.
@return Serializable The deserialized object from the message
@exception IOException The object could not be deserialized
@exception ClassNotFoundException A class required to deserialize the object could not be found. | [
"Private",
"method",
"to",
"deserialize",
"the",
"real",
"object",
"from",
"the",
"payload",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsJmsObjectMessageImpl.java#L436-L488 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/ProducerSessionImpl.java | ProducerSessionImpl.getConnection | public SICoreConnection getConnection() throws SISessionUnavailableException
{
if (TraceComponent.isAnyTracingEnabled() && CoreSPIProducerSession.tc.isEntryEnabled())
{
SibTr.entry(CoreSPIProducerSession.tc, "getConnection", this);
SibTr.exit(CoreSPIProducerSession.tc, "getConnection", _conn);
}
checkNotClosed();
return _conn;
} | java | public SICoreConnection getConnection() throws SISessionUnavailableException
{
if (TraceComponent.isAnyTracingEnabled() && CoreSPIProducerSession.tc.isEntryEnabled())
{
SibTr.entry(CoreSPIProducerSession.tc, "getConnection", this);
SibTr.exit(CoreSPIProducerSession.tc, "getConnection", _conn);
}
checkNotClosed();
return _conn;
} | [
"public",
"SICoreConnection",
"getConnection",
"(",
")",
"throws",
"SISessionUnavailableException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"CoreSPIProducerSession",
".",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"SibTr",
".",
"entry",
"(",
"CoreSPIProducerSession",
".",
"tc",
",",
"\"getConnection\"",
",",
"this",
")",
";",
"SibTr",
".",
"exit",
"(",
"CoreSPIProducerSession",
".",
"tc",
",",
"\"getConnection\"",
",",
"_conn",
")",
";",
"}",
"checkNotClosed",
"(",
")",
";",
"return",
"_conn",
";",
"}"
] | Returns this sessions connection | [
"Returns",
"this",
"sessions",
"connection"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/ProducerSessionImpl.java#L608-L617 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/ProducerSessionImpl.java | ProducerSessionImpl.disableDiscriminatorAccessCheckAtSend | void disableDiscriminatorAccessCheckAtSend(String discriminatorAtCreate)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "disableDiscriminatorAccessCheckAtSend");
_checkDiscriminatorAccessAtSend = false;
this._discriminatorAtCreate = discriminatorAtCreate;
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "disableDiscriminatorAccessCheckAtSend");
} | java | void disableDiscriminatorAccessCheckAtSend(String discriminatorAtCreate)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "disableDiscriminatorAccessCheckAtSend");
_checkDiscriminatorAccessAtSend = false;
this._discriminatorAtCreate = discriminatorAtCreate;
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "disableDiscriminatorAccessCheckAtSend");
} | [
"void",
"disableDiscriminatorAccessCheckAtSend",
"(",
"String",
"discriminatorAtCreate",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"disableDiscriminatorAccessCheckAtSend\"",
")",
";",
"_checkDiscriminatorAccessAtSend",
"=",
"false",
";",
"this",
".",
"_discriminatorAtCreate",
"=",
"discriminatorAtCreate",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"disableDiscriminatorAccessCheckAtSend\"",
")",
";",
"}"
] | Disable discriminator access checks at send time | [
"Disable",
"discriminator",
"access",
"checks",
"at",
"send",
"time"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/ProducerSessionImpl.java#L696-L706 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.channelfw/src/com/ibm/io/async/TimeSlot.java | TimeSlot.addEntry | public void addEntry(TimerWorkItem addItem, long curTime) {
// this routine assumes the slot is not full
this.mostRecentlyAccessedTime = curTime;
this.lastEntryIndex++;
this.entries[lastEntryIndex] = addItem;
} | java | public void addEntry(TimerWorkItem addItem, long curTime) {
// this routine assumes the slot is not full
this.mostRecentlyAccessedTime = curTime;
this.lastEntryIndex++;
this.entries[lastEntryIndex] = addItem;
} | [
"public",
"void",
"addEntry",
"(",
"TimerWorkItem",
"addItem",
",",
"long",
"curTime",
")",
"{",
"// this routine assumes the slot is not full",
"this",
".",
"mostRecentlyAccessedTime",
"=",
"curTime",
";",
"this",
".",
"lastEntryIndex",
"++",
";",
"this",
".",
"entries",
"[",
"lastEntryIndex",
"]",
"=",
"addItem",
";",
"}"
] | Add a timer item.
@param addItem
@param curTime | [
"Add",
"a",
"timer",
"item",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/io/async/TimeSlot.java#L69-L75 | train |
OpenLiberty/open-liberty | dev/com.ibm.jbatch.jsl.model/src/com/ibm/jbatch/jsl/model/Split.java | Split.getFlows | @Generated(value = "com.ibm.jtc.jax.tools.xjc.Driver", date = "2014-06-11T05:49:00-04:00", comments = "JAXB RI v2.2.3-11/28/2011 06:21 AM(foreman)-")
public List<Flow> getFlows() {
if (flows == null) {
flows = new ArrayList<Flow>();
}
return this.flows;
} | java | @Generated(value = "com.ibm.jtc.jax.tools.xjc.Driver", date = "2014-06-11T05:49:00-04:00", comments = "JAXB RI v2.2.3-11/28/2011 06:21 AM(foreman)-")
public List<Flow> getFlows() {
if (flows == null) {
flows = new ArrayList<Flow>();
}
return this.flows;
} | [
"@",
"Generated",
"(",
"value",
"=",
"\"com.ibm.jtc.jax.tools.xjc.Driver\"",
",",
"date",
"=",
"\"2014-06-11T05:49:00-04:00\"",
",",
"comments",
"=",
"\"JAXB RI v2.2.3-11/28/2011 06:21 AM(foreman)-\"",
")",
"public",
"List",
"<",
"Flow",
">",
"getFlows",
"(",
")",
"{",
"if",
"(",
"flows",
"==",
"null",
")",
"{",
"flows",
"=",
"new",
"ArrayList",
"<",
"Flow",
">",
"(",
")",
";",
"}",
"return",
"this",
".",
"flows",
";",
"}"
] | Gets the value of the flows property.
<p>
This accessor method returns a reference to the live list,
not a snapshot. Therefore any modification you make to the
returned list will be present inside the JAXB object.
This is why there is not a <CODE>set</CODE> method for the flows property.
<p>
For example, to add a new item, do as follows:
<pre>
getFlows().add(newItem);
</pre>
<p>
Objects of the following type(s) are allowed in the list
{@link Flow } | [
"Gets",
"the",
"value",
"of",
"the",
"flows",
"property",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.jbatch.jsl.model/src/com/ibm/jbatch/jsl/model/Split.java#L96-L102 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/impl/JSchemaInterpreterImpl.java | JSchemaInterpreterImpl.decode | public JMFMessage decode(JSchema schema, byte[] contents, int offset, int length)
throws JMFMessageCorruptionException {
return new JSMessageImpl(schema, contents, offset, length, true);
} | java | public JMFMessage decode(JSchema schema, byte[] contents, int offset, int length)
throws JMFMessageCorruptionException {
return new JSMessageImpl(schema, contents, offset, length, true);
} | [
"public",
"JMFMessage",
"decode",
"(",
"JSchema",
"schema",
",",
"byte",
"[",
"]",
"contents",
",",
"int",
"offset",
",",
"int",
"length",
")",
"throws",
"JMFMessageCorruptionException",
"{",
"return",
"new",
"JSMessageImpl",
"(",
"schema",
",",
"contents",
",",
"offset",
",",
"length",
",",
"true",
")",
";",
"}"
] | Implementation of decode | [
"Implementation",
"of",
"decode"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/impl/JSchemaInterpreterImpl.java#L39-L42 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/ServerCommand.java | ServerCommand.read | protected String read(SocketChannel sc) throws IOException {
sc.read(buffer);
buffer.flip();
decoder.decode(buffer, charBuffer, true);
charBuffer.flip();
String result = charBuffer.toString();
// Clear out buffers
buffer.clear();
charBuffer.clear();
decoder.reset();
return result;
} | java | protected String read(SocketChannel sc) throws IOException {
sc.read(buffer);
buffer.flip();
decoder.decode(buffer, charBuffer, true);
charBuffer.flip();
String result = charBuffer.toString();
// Clear out buffers
buffer.clear();
charBuffer.clear();
decoder.reset();
return result;
} | [
"protected",
"String",
"read",
"(",
"SocketChannel",
"sc",
")",
"throws",
"IOException",
"{",
"sc",
".",
"read",
"(",
"buffer",
")",
";",
"buffer",
".",
"flip",
"(",
")",
";",
"decoder",
".",
"decode",
"(",
"buffer",
",",
"charBuffer",
",",
"true",
")",
";",
"charBuffer",
".",
"flip",
"(",
")",
";",
"String",
"result",
"=",
"charBuffer",
".",
"toString",
"(",
")",
";",
"// Clear out buffers",
"buffer",
".",
"clear",
"(",
")",
";",
"charBuffer",
".",
"clear",
"(",
")",
";",
"decoder",
".",
"reset",
"(",
")",
";",
"return",
"result",
";",
"}"
] | Reads a command or command response from a socket channel.
<p>This method is not safe for use by multiple concurrent threads.
@param sc the socket channel
@return the command or command response | [
"Reads",
"a",
"command",
"or",
"command",
"response",
"from",
"a",
"socket",
"channel",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/ServerCommand.java#L73-L88 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/ServerCommand.java | ServerCommand.write | protected void write(SocketChannel sc, String s) throws IOException {
sc.write(encoder.encode(CharBuffer.wrap(s)));
} | java | protected void write(SocketChannel sc, String s) throws IOException {
sc.write(encoder.encode(CharBuffer.wrap(s)));
} | [
"protected",
"void",
"write",
"(",
"SocketChannel",
"sc",
",",
"String",
"s",
")",
"throws",
"IOException",
"{",
"sc",
".",
"write",
"(",
"encoder",
".",
"encode",
"(",
"CharBuffer",
".",
"wrap",
"(",
"s",
")",
")",
")",
";",
"}"
] | Writes a command or command response to a socket channel.
<p>This method is not safe for use by multiple concurrent threads.
@param sc the socket channel
@param s the command or command response | [
"Writes",
"a",
"command",
"or",
"command",
"response",
"to",
"a",
"socket",
"channel",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/ServerCommand.java#L98-L100 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.mp.jwt_fat/fat/src/com/ibm/ws/security/mp/jwt/fat/MPJwtBadMPConfigAsEnvVars.java | MPJwtBadMPConfigAsEnvVars.MPJwtBadMPConfigAsEnvVars_GoodMpJwtConfigSpecifiedInServerXml | @Test
public void MPJwtBadMPConfigAsEnvVars_GoodMpJwtConfigSpecifiedInServerXml() throws Exception {
resourceServer.reconfigureServerUsingExpandedConfiguration(_testName, "rs_server_AltConfigNotInApp_goodServerXmlConfig.xml");
standardTestFlow(resourceServer, MpJwtFatConstants.NO_MP_CONFIG_IN_APP_ROOT_CONTEXT,
MpJwtFatConstants.NO_MP_CONFIG_IN_APP_APP, MpJwtFatConstants.MPJWT_APP_CLASS_NO_MP_CONFIG_IN_APP);
} | java | @Test
public void MPJwtBadMPConfigAsEnvVars_GoodMpJwtConfigSpecifiedInServerXml() throws Exception {
resourceServer.reconfigureServerUsingExpandedConfiguration(_testName, "rs_server_AltConfigNotInApp_goodServerXmlConfig.xml");
standardTestFlow(resourceServer, MpJwtFatConstants.NO_MP_CONFIG_IN_APP_ROOT_CONTEXT,
MpJwtFatConstants.NO_MP_CONFIG_IN_APP_APP, MpJwtFatConstants.MPJWT_APP_CLASS_NO_MP_CONFIG_IN_APP);
} | [
"@",
"Test",
"public",
"void",
"MPJwtBadMPConfigAsEnvVars_GoodMpJwtConfigSpecifiedInServerXml",
"(",
")",
"throws",
"Exception",
"{",
"resourceServer",
".",
"reconfigureServerUsingExpandedConfiguration",
"(",
"_testName",
",",
"\"rs_server_AltConfigNotInApp_goodServerXmlConfig.xml\"",
")",
";",
"standardTestFlow",
"(",
"resourceServer",
",",
"MpJwtFatConstants",
".",
"NO_MP_CONFIG_IN_APP_ROOT_CONTEXT",
",",
"MpJwtFatConstants",
".",
"NO_MP_CONFIG_IN_APP_APP",
",",
"MpJwtFatConstants",
".",
"MPJWT_APP_CLASS_NO_MP_CONFIG_IN_APP",
")",
";",
"}"
] | The server will be started with all mp-config properties set to bad values in environment variables.
The server.xml has a valid mp_jwt config specified.
The config settings should come from server.xml.
The test should run successfully .
@throws Exception | [
"The",
"server",
"will",
"be",
"started",
"with",
"all",
"mp",
"-",
"config",
"properties",
"set",
"to",
"bad",
"values",
"in",
"environment",
"variables",
".",
"The",
"server",
".",
"xml",
"has",
"a",
"valid",
"mp_jwt",
"config",
"specified",
".",
"The",
"config",
"settings",
"should",
"come",
"from",
"server",
".",
"xml",
".",
"The",
"test",
"should",
"run",
"successfully",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.mp.jwt_fat/fat/src/com/ibm/ws/security/mp/jwt/fat/MPJwtBadMPConfigAsEnvVars.java#L66-L73 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.mp.jwt_fat/fat/src/com/ibm/ws/security/mp/jwt/fat/MPJwtBadMPConfigAsEnvVars.java | MPJwtBadMPConfigAsEnvVars.MPJwtBadMPConfigAsEnvVars_MpJwtConfigNotSpecifiedInServerXml | @Test
public void MPJwtBadMPConfigAsEnvVars_MpJwtConfigNotSpecifiedInServerXml() throws Exception {
standardTestFlow(resourceServer, MpJwtFatConstants.NO_MP_CONFIG_IN_APP_ROOT_CONTEXT,
MpJwtFatConstants.NO_MP_CONFIG_IN_APP_APP, MpJwtFatConstants.MPJWT_APP_CLASS_NO_MP_CONFIG_IN_APP,
setBadIssuerExpectations(resourceServer));
} | java | @Test
public void MPJwtBadMPConfigAsEnvVars_MpJwtConfigNotSpecifiedInServerXml() throws Exception {
standardTestFlow(resourceServer, MpJwtFatConstants.NO_MP_CONFIG_IN_APP_ROOT_CONTEXT,
MpJwtFatConstants.NO_MP_CONFIG_IN_APP_APP, MpJwtFatConstants.MPJWT_APP_CLASS_NO_MP_CONFIG_IN_APP,
setBadIssuerExpectations(resourceServer));
} | [
"@",
"Test",
"public",
"void",
"MPJwtBadMPConfigAsEnvVars_MpJwtConfigNotSpecifiedInServerXml",
"(",
")",
"throws",
"Exception",
"{",
"standardTestFlow",
"(",
"resourceServer",
",",
"MpJwtFatConstants",
".",
"NO_MP_CONFIG_IN_APP_ROOT_CONTEXT",
",",
"MpJwtFatConstants",
".",
"NO_MP_CONFIG_IN_APP_APP",
",",
"MpJwtFatConstants",
".",
"MPJWT_APP_CLASS_NO_MP_CONFIG_IN_APP",
",",
"setBadIssuerExpectations",
"(",
"resourceServer",
")",
")",
";",
"}"
] | The server will be started with all mp-config properties set to bad values in environment variables.
The server.xml has NO mp_jwt config specified.
The config settings should come from the env vars.
The test should fail
@throws Exception | [
"The",
"server",
"will",
"be",
"started",
"with",
"all",
"mp",
"-",
"config",
"properties",
"set",
"to",
"bad",
"values",
"in",
"environment",
"variables",
".",
"The",
"server",
".",
"xml",
"has",
"NO",
"mp_jwt",
"config",
"specified",
".",
"The",
"config",
"settings",
"should",
"come",
"from",
"the",
"env",
"vars",
".",
"The",
"test",
"should",
"fail"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.mp.jwt_fat/fat/src/com/ibm/ws/security/mp/jwt/fat/MPJwtBadMPConfigAsEnvVars.java#L83-L90 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java | UpgradeInputByteBufferUtil.doRead | private boolean doRead(int amountToRead) throws IOException{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "doRead, Current buffer, " + _buffer + ", reading from the TCP Channel, readLine : " + _isReadLine);
}
try {
if(_tcpChannelCallback != null && !_isReadLine){
//async read logic
return immediateRead(amountToRead);
} else {
return syncRead(amountToRead);
}
} catch (IOException e) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "doRead, we encountered an exception during the read : " + e);
}
if(_error != null){
return false;
}
_error = e;
throw e;
}
} | java | private boolean doRead(int amountToRead) throws IOException{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "doRead, Current buffer, " + _buffer + ", reading from the TCP Channel, readLine : " + _isReadLine);
}
try {
if(_tcpChannelCallback != null && !_isReadLine){
//async read logic
return immediateRead(amountToRead);
} else {
return syncRead(amountToRead);
}
} catch (IOException e) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "doRead, we encountered an exception during the read : " + e);
}
if(_error != null){
return false;
}
_error = e;
throw e;
}
} | [
"private",
"boolean",
"doRead",
"(",
"int",
"amountToRead",
")",
"throws",
"IOException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"doRead, Current buffer, \"",
"+",
"_buffer",
"+",
"\", reading from the TCP Channel, readLine : \"",
"+",
"_isReadLine",
")",
";",
"}",
"try",
"{",
"if",
"(",
"_tcpChannelCallback",
"!=",
"null",
"&&",
"!",
"_isReadLine",
")",
"{",
"//async read logic",
"return",
"immediateRead",
"(",
"amountToRead",
")",
";",
"}",
"else",
"{",
"return",
"syncRead",
"(",
"amountToRead",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"doRead, we encountered an exception during the read : \"",
"+",
"e",
")",
";",
"}",
"if",
"(",
"_error",
"!=",
"null",
")",
"{",
"return",
"false",
";",
"}",
"_error",
"=",
"e",
";",
"throw",
"e",
";",
"}",
"}"
] | This method will call the synchronous or asynchronous method depending on how everything is set up
@return If we have read any data or not
@throws IOException | [
"This",
"method",
"will",
"call",
"the",
"synchronous",
"or",
"asynchronous",
"method",
"depending",
"on",
"how",
"everything",
"is",
"set",
"up"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java#L87-L111 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java | UpgradeInputByteBufferUtil.syncRead | private boolean syncRead(int amountToRead) throws IOException{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "syncRead, Executing a synchronous read");
}
// Allocate the buffer and set it on the TCP Channel
setAndAllocateBuffer(amountToRead);
try{
long bytesRead = _tcpContext.getReadInterface().read(1, WCCustomProperties31.UPGRADE_READ_TIMEOUT);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "syncRead, Completed the read, " + bytesRead);
}
if(bytesRead > 0){
//Get the buffer from the TCP Channel after we have told them to read.
_buffer = _tcpContext.getReadInterface().getBuffer();
//We don't need to check for null first as we know we will always get the buffer we just set
configurePostReadBuffer();
// record the new amount of data read from the channel
_totalBytesRead += _buffer.remaining();
return true;
}
return false;
}catch (IOException e){
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "syncRead, We encountered an exception during the read : " + e);
}
_error = e;
throw e;
}
} | java | private boolean syncRead(int amountToRead) throws IOException{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "syncRead, Executing a synchronous read");
}
// Allocate the buffer and set it on the TCP Channel
setAndAllocateBuffer(amountToRead);
try{
long bytesRead = _tcpContext.getReadInterface().read(1, WCCustomProperties31.UPGRADE_READ_TIMEOUT);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "syncRead, Completed the read, " + bytesRead);
}
if(bytesRead > 0){
//Get the buffer from the TCP Channel after we have told them to read.
_buffer = _tcpContext.getReadInterface().getBuffer();
//We don't need to check for null first as we know we will always get the buffer we just set
configurePostReadBuffer();
// record the new amount of data read from the channel
_totalBytesRead += _buffer.remaining();
return true;
}
return false;
}catch (IOException e){
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "syncRead, We encountered an exception during the read : " + e);
}
_error = e;
throw e;
}
} | [
"private",
"boolean",
"syncRead",
"(",
"int",
"amountToRead",
")",
"throws",
"IOException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"syncRead, Executing a synchronous read\"",
")",
";",
"}",
"// Allocate the buffer and set it on the TCP Channel",
"setAndAllocateBuffer",
"(",
"amountToRead",
")",
";",
"try",
"{",
"long",
"bytesRead",
"=",
"_tcpContext",
".",
"getReadInterface",
"(",
")",
".",
"read",
"(",
"1",
",",
"WCCustomProperties31",
".",
"UPGRADE_READ_TIMEOUT",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"syncRead, Completed the read, \"",
"+",
"bytesRead",
")",
";",
"}",
"if",
"(",
"bytesRead",
">",
"0",
")",
"{",
"//Get the buffer from the TCP Channel after we have told them to read.",
"_buffer",
"=",
"_tcpContext",
".",
"getReadInterface",
"(",
")",
".",
"getBuffer",
"(",
")",
";",
"//We don't need to check for null first as we know we will always get the buffer we just set",
"configurePostReadBuffer",
"(",
")",
";",
"// record the new amount of data read from the channel",
"_totalBytesRead",
"+=",
"_buffer",
".",
"remaining",
"(",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"syncRead, We encountered an exception during the read : \"",
"+",
"e",
")",
";",
"}",
"_error",
"=",
"e",
";",
"throw",
"e",
";",
"}",
"}"
] | Issues a synchronous read to the TCP Channel.
@return If we have read any data or not
@throws IOException | [
"Issues",
"a",
"synchronous",
"read",
"to",
"the",
"TCP",
"Channel",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java#L119-L151 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java | UpgradeInputByteBufferUtil.immediateRead | private boolean immediateRead(int amountToRead){
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "immediateRead, Executing a read");
}
if(amountToRead > 1){
//Allocate a new temp buffer, then set the position to 0 and limit to the amount we want to read
//Copy in the current this.buffer as it should only have one byte in it
WsByteBuffer tempBuffer = allocateBuffer(amountToRead);
tempBuffer.position(0);
tempBuffer.limit(amountToRead);
tempBuffer.put(_buffer);
tempBuffer.position(1);
_buffer.release();
_buffer = tempBuffer;
tempBuffer = null;
_tcpContext.getReadInterface().setBuffer(_buffer);
long bytesRead = 0;
try{
bytesRead = _tcpContext.getReadInterface().read(0, WCCustomProperties31.UPGRADE_READ_TIMEOUT);
} catch (IOException readException){
//If we encounter an exception here we need to return the 1 byte that we already have.
//Returned true immediately and the next read will catch the exception and propagate it properly
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "immediateRead, The read encountered an exception. " + readException);
Tr.debug(tc, "immediateRead, Return with our one byte");
}
configurePostReadBuffer();
return true;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "immediateRead, Complete, " + bytesRead);
}
//Get the buffer from the TCP Channel after we have told them to read.
_buffer = _tcpContext.getReadInterface().getBuffer();
//We don't need to check for null first as we know we will always get the buffer we just set
configurePostReadBuffer();
// record the new amount of data read from the channel
_totalBytesRead += _buffer.remaining();
}
//We will return true here in all circumstances because we always have 1 byte read from the isReady call or the initial read of the connection
return true;
} | java | private boolean immediateRead(int amountToRead){
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "immediateRead, Executing a read");
}
if(amountToRead > 1){
//Allocate a new temp buffer, then set the position to 0 and limit to the amount we want to read
//Copy in the current this.buffer as it should only have one byte in it
WsByteBuffer tempBuffer = allocateBuffer(amountToRead);
tempBuffer.position(0);
tempBuffer.limit(amountToRead);
tempBuffer.put(_buffer);
tempBuffer.position(1);
_buffer.release();
_buffer = tempBuffer;
tempBuffer = null;
_tcpContext.getReadInterface().setBuffer(_buffer);
long bytesRead = 0;
try{
bytesRead = _tcpContext.getReadInterface().read(0, WCCustomProperties31.UPGRADE_READ_TIMEOUT);
} catch (IOException readException){
//If we encounter an exception here we need to return the 1 byte that we already have.
//Returned true immediately and the next read will catch the exception and propagate it properly
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "immediateRead, The read encountered an exception. " + readException);
Tr.debug(tc, "immediateRead, Return with our one byte");
}
configurePostReadBuffer();
return true;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "immediateRead, Complete, " + bytesRead);
}
//Get the buffer from the TCP Channel after we have told them to read.
_buffer = _tcpContext.getReadInterface().getBuffer();
//We don't need to check for null first as we know we will always get the buffer we just set
configurePostReadBuffer();
// record the new amount of data read from the channel
_totalBytesRead += _buffer.remaining();
}
//We will return true here in all circumstances because we always have 1 byte read from the isReady call or the initial read of the connection
return true;
} | [
"private",
"boolean",
"immediateRead",
"(",
"int",
"amountToRead",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"immediateRead, Executing a read\"",
")",
";",
"}",
"if",
"(",
"amountToRead",
">",
"1",
")",
"{",
"//Allocate a new temp buffer, then set the position to 0 and limit to the amount we want to read",
"//Copy in the current this.buffer as it should only have one byte in it",
"WsByteBuffer",
"tempBuffer",
"=",
"allocateBuffer",
"(",
"amountToRead",
")",
";",
"tempBuffer",
".",
"position",
"(",
"0",
")",
";",
"tempBuffer",
".",
"limit",
"(",
"amountToRead",
")",
";",
"tempBuffer",
".",
"put",
"(",
"_buffer",
")",
";",
"tempBuffer",
".",
"position",
"(",
"1",
")",
";",
"_buffer",
".",
"release",
"(",
")",
";",
"_buffer",
"=",
"tempBuffer",
";",
"tempBuffer",
"=",
"null",
";",
"_tcpContext",
".",
"getReadInterface",
"(",
")",
".",
"setBuffer",
"(",
"_buffer",
")",
";",
"long",
"bytesRead",
"=",
"0",
";",
"try",
"{",
"bytesRead",
"=",
"_tcpContext",
".",
"getReadInterface",
"(",
")",
".",
"read",
"(",
"0",
",",
"WCCustomProperties31",
".",
"UPGRADE_READ_TIMEOUT",
")",
";",
"}",
"catch",
"(",
"IOException",
"readException",
")",
"{",
"//If we encounter an exception here we need to return the 1 byte that we already have.",
"//Returned true immediately and the next read will catch the exception and propagate it properly",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"immediateRead, The read encountered an exception. \"",
"+",
"readException",
")",
";",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"immediateRead, Return with our one byte\"",
")",
";",
"}",
"configurePostReadBuffer",
"(",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"immediateRead, Complete, \"",
"+",
"bytesRead",
")",
";",
"}",
"//Get the buffer from the TCP Channel after we have told them to read.",
"_buffer",
"=",
"_tcpContext",
".",
"getReadInterface",
"(",
")",
".",
"getBuffer",
"(",
")",
";",
"//We don't need to check for null first as we know we will always get the buffer we just set",
"configurePostReadBuffer",
"(",
")",
";",
"// record the new amount of data read from the channel",
"_totalBytesRead",
"+=",
"_buffer",
".",
"remaining",
"(",
")",
";",
"}",
"//We will return true here in all circumstances because we always have 1 byte read from the isReady call or the initial read of the connection",
"return",
"true",
";",
"}"
] | This method will execute an immediate read
The immediate read will issue a read to the TCP Channel and immediately return with whatever can fit in the buffers
This will only ever be called after we had read the 1 byte from the isReady or initialRead methods. As such
we will allocate a buffer and add in the 1 byte. This method should always return at least 1 byte, even if the
read fails, since we have already read that byte
@return If we have read any data or not
@throws IOException | [
"This",
"method",
"will",
"execute",
"an",
"immediate",
"read",
"The",
"immediate",
"read",
"will",
"issue",
"a",
"read",
"to",
"the",
"TCP",
"Channel",
"and",
"immediately",
"return",
"with",
"whatever",
"can",
"fit",
"in",
"the",
"buffers",
"This",
"will",
"only",
"ever",
"be",
"called",
"after",
"we",
"had",
"read",
"the",
"1",
"byte",
"from",
"the",
"isReady",
"or",
"initialRead",
"methods",
".",
"As",
"such",
"we",
"will",
"allocate",
"a",
"buffer",
"and",
"add",
"in",
"the",
"1",
"byte",
".",
"This",
"method",
"should",
"always",
"return",
"at",
"least",
"1",
"byte",
"even",
"if",
"the",
"read",
"fails",
"since",
"we",
"have",
"already",
"read",
"that",
"byte"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java#L163-L212 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java | UpgradeInputByteBufferUtil.read | public int read() throws IOException {
validate();
int rc = -1;
if(doRead(1)){
rc = _buffer.get() & 0x000000FF;
}
_buffer.release();
_buffer = null;
return rc;
} | java | public int read() throws IOException {
validate();
int rc = -1;
if(doRead(1)){
rc = _buffer.get() & 0x000000FF;
}
_buffer.release();
_buffer = null;
return rc;
} | [
"public",
"int",
"read",
"(",
")",
"throws",
"IOException",
"{",
"validate",
"(",
")",
";",
"int",
"rc",
"=",
"-",
"1",
";",
"if",
"(",
"doRead",
"(",
"1",
")",
")",
"{",
"rc",
"=",
"_buffer",
".",
"get",
"(",
")",
"&",
"0x000000FF",
";",
"}",
"_buffer",
".",
"release",
"(",
")",
";",
"_buffer",
"=",
"null",
";",
"return",
"rc",
";",
"}"
] | Read the first available byte
@return int - the byte read
@throws IOException | [
"Read",
"the",
"first",
"available",
"byte"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java#L220-L232 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java | UpgradeInputByteBufferUtil.read | public int read(byte[] output, int offset, int length) throws IOException {
int size = -1;
validate();
if (0 == length) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "read(byte[],int,int), Target length was 0");
}
return length;
}
if(doRead(length)){
size = _buffer.limit() - _buffer.position();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
{
Tr.debug(tc, "(byte[],int,int) Filling byte array, size --> " + size);
}
_buffer.get(output, offset, size);
}
_buffer.release();
_buffer = null;
return size;
} | java | public int read(byte[] output, int offset, int length) throws IOException {
int size = -1;
validate();
if (0 == length) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "read(byte[],int,int), Target length was 0");
}
return length;
}
if(doRead(length)){
size = _buffer.limit() - _buffer.position();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
{
Tr.debug(tc, "(byte[],int,int) Filling byte array, size --> " + size);
}
_buffer.get(output, offset, size);
}
_buffer.release();
_buffer = null;
return size;
} | [
"public",
"int",
"read",
"(",
"byte",
"[",
"]",
"output",
",",
"int",
"offset",
",",
"int",
"length",
")",
"throws",
"IOException",
"{",
"int",
"size",
"=",
"-",
"1",
";",
"validate",
"(",
")",
";",
"if",
"(",
"0",
"==",
"length",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"read(byte[],int,int), Target length was 0\"",
")",
";",
"}",
"return",
"length",
";",
"}",
"if",
"(",
"doRead",
"(",
"length",
")",
")",
"{",
"size",
"=",
"_buffer",
".",
"limit",
"(",
")",
"-",
"_buffer",
".",
"position",
"(",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"(byte[],int,int) Filling byte array, size --> \"",
"+",
"size",
")",
";",
"}",
"_buffer",
".",
"get",
"(",
"output",
",",
"offset",
",",
"size",
")",
";",
"}",
"_buffer",
".",
"release",
"(",
")",
";",
"_buffer",
"=",
"null",
";",
"return",
"size",
";",
"}"
] | Read into the provided byte array with the length and offset provided
@param output
@param offset
@param length
@return int - the number of bytes read
@throws IOException | [
"Read",
"into",
"the",
"provided",
"byte",
"array",
"with",
"the",
"length",
"and",
"offset",
"provided"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java#L254-L279 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java | UpgradeInputByteBufferUtil.setAndAllocateBuffer | private void setAndAllocateBuffer(int sizeToAllocate) {
if(_buffer == null){
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "setAndAllocateBuffer, Buffer is null, size to allocate is : " + sizeToAllocate);
}
_buffer = allocateBuffer(sizeToAllocate);
}
configurePreReadBuffer(sizeToAllocate);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "setAndAllocateBuffer, Setting the buffer : " + _buffer );
}
_tcpContext.getReadInterface().setBuffer(_buffer);
} | java | private void setAndAllocateBuffer(int sizeToAllocate) {
if(_buffer == null){
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "setAndAllocateBuffer, Buffer is null, size to allocate is : " + sizeToAllocate);
}
_buffer = allocateBuffer(sizeToAllocate);
}
configurePreReadBuffer(sizeToAllocate);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "setAndAllocateBuffer, Setting the buffer : " + _buffer );
}
_tcpContext.getReadInterface().setBuffer(_buffer);
} | [
"private",
"void",
"setAndAllocateBuffer",
"(",
"int",
"sizeToAllocate",
")",
"{",
"if",
"(",
"_buffer",
"==",
"null",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"setAndAllocateBuffer, Buffer is null, size to allocate is : \"",
"+",
"sizeToAllocate",
")",
";",
"}",
"_buffer",
"=",
"allocateBuffer",
"(",
"sizeToAllocate",
")",
";",
"}",
"configurePreReadBuffer",
"(",
"sizeToAllocate",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"setAndAllocateBuffer, Setting the buffer : \"",
"+",
"_buffer",
")",
";",
"}",
"_tcpContext",
".",
"getReadInterface",
"(",
")",
".",
"setBuffer",
"(",
"_buffer",
")",
";",
"}"
] | Allocate the buffer size we need and then pre-configure the buffer to prepare it to be read into
Once it has been prepared set the buffer to the TCP Channel | [
"Allocate",
"the",
"buffer",
"size",
"we",
"need",
"and",
"then",
"pre",
"-",
"configure",
"the",
"buffer",
"to",
"prepare",
"it",
"to",
"be",
"read",
"into",
"Once",
"it",
"has",
"been",
"prepared",
"set",
"the",
"buffer",
"to",
"the",
"TCP",
"Channel"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java#L285-L301 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java | UpgradeInputByteBufferUtil.validate | private void validate() throws IOException {
if (null != _error) {
throw _error;
}
if(!_isReadLine && !_isReady){
//If there is no data available then isReady will have returned false and this throw an IllegalStateException
if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
Tr.error(tc, "read.failed.isReady.false");
throw new IllegalStateException(Tr.formatMessage(tc, "read.failed.isReady.false"));
}
} | java | private void validate() throws IOException {
if (null != _error) {
throw _error;
}
if(!_isReadLine && !_isReady){
//If there is no data available then isReady will have returned false and this throw an IllegalStateException
if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
Tr.error(tc, "read.failed.isReady.false");
throw new IllegalStateException(Tr.formatMessage(tc, "read.failed.isReady.false"));
}
} | [
"private",
"void",
"validate",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"null",
"!=",
"_error",
")",
"{",
"throw",
"_error",
";",
"}",
"if",
"(",
"!",
"_isReadLine",
"&&",
"!",
"_isReady",
")",
"{",
"//If there is no data available then isReady will have returned false and this throw an IllegalStateException",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isErrorEnabled",
"(",
")",
")",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"read.failed.isReady.false\"",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"Tr",
".",
"formatMessage",
"(",
"tc",
",",
"\"read.failed.isReady.false\"",
")",
")",
";",
"}",
"}"
] | This checks if we have already had an exception thrown. If so it just rethrows that exception
This check is done before any reads are done
@throws IOException | [
"This",
"checks",
"if",
"we",
"have",
"already",
"had",
"an",
"exception",
"thrown",
".",
"If",
"so",
"it",
"just",
"rethrows",
"that",
"exception",
"This",
"check",
"is",
"done",
"before",
"any",
"reads",
"are",
"done"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java#L309-L320 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java | UpgradeInputByteBufferUtil.setupReadListener | public void setupReadListener(ReadListener readListenerl, SRTUpgradeInputStream31 srtUpgradeStream){
if(readListenerl == null){
if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
Tr.error(tc, "readlistener.is.null");
throw new NullPointerException(Tr.formatMessage(tc, "readlistener.is.null"));
}
if(_rl != null){
if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
Tr.error(tc, "readlistener.already.started");
throw new IllegalStateException(Tr.formatMessage(tc, "readlistener.already.started"));
}
//Save off the current Thread data by creating the ThreadContextManager. Then pass it into the callback
ThreadContextManager tcm = new ThreadContextManager();
_tcpChannelCallback = new UpgradeReadCallback(readListenerl, this, tcm, srtUpgradeStream);
_rl = readListenerl;
_isReady = false;
_upConn.getVirtualConnection().getStateMap().put(TransportConstants.UPGRADED_LISTENER, "true");
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "setupReadListener, Starting the initial read");
}
initialRead();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "setupReadListener, ReadListener set : " + _rl);
}
} | java | public void setupReadListener(ReadListener readListenerl, SRTUpgradeInputStream31 srtUpgradeStream){
if(readListenerl == null){
if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
Tr.error(tc, "readlistener.is.null");
throw new NullPointerException(Tr.formatMessage(tc, "readlistener.is.null"));
}
if(_rl != null){
if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
Tr.error(tc, "readlistener.already.started");
throw new IllegalStateException(Tr.formatMessage(tc, "readlistener.already.started"));
}
//Save off the current Thread data by creating the ThreadContextManager. Then pass it into the callback
ThreadContextManager tcm = new ThreadContextManager();
_tcpChannelCallback = new UpgradeReadCallback(readListenerl, this, tcm, srtUpgradeStream);
_rl = readListenerl;
_isReady = false;
_upConn.getVirtualConnection().getStateMap().put(TransportConstants.UPGRADED_LISTENER, "true");
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "setupReadListener, Starting the initial read");
}
initialRead();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "setupReadListener, ReadListener set : " + _rl);
}
} | [
"public",
"void",
"setupReadListener",
"(",
"ReadListener",
"readListenerl",
",",
"SRTUpgradeInputStream31",
"srtUpgradeStream",
")",
"{",
"if",
"(",
"readListenerl",
"==",
"null",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isErrorEnabled",
"(",
")",
")",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"readlistener.is.null\"",
")",
";",
"throw",
"new",
"NullPointerException",
"(",
"Tr",
".",
"formatMessage",
"(",
"tc",
",",
"\"readlistener.is.null\"",
")",
")",
";",
"}",
"if",
"(",
"_rl",
"!=",
"null",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isErrorEnabled",
"(",
")",
")",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"readlistener.already.started\"",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"Tr",
".",
"formatMessage",
"(",
"tc",
",",
"\"readlistener.already.started\"",
")",
")",
";",
"}",
"//Save off the current Thread data by creating the ThreadContextManager. Then pass it into the callback ",
"ThreadContextManager",
"tcm",
"=",
"new",
"ThreadContextManager",
"(",
")",
";",
"_tcpChannelCallback",
"=",
"new",
"UpgradeReadCallback",
"(",
"readListenerl",
",",
"this",
",",
"tcm",
",",
"srtUpgradeStream",
")",
";",
"_rl",
"=",
"readListenerl",
";",
"_isReady",
"=",
"false",
";",
"_upConn",
".",
"getVirtualConnection",
"(",
")",
".",
"getStateMap",
"(",
")",
".",
"put",
"(",
"TransportConstants",
".",
"UPGRADED_LISTENER",
",",
"\"true\"",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"setupReadListener, Starting the initial read\"",
")",
";",
"}",
"initialRead",
"(",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"setupReadListener, ReadListener set : \"",
"+",
"_rl",
")",
";",
"}",
"}"
] | Sets the ReadListener provided by the application to this stream
Once the ReadListener is set we will kick off the initial read
@param readListenerl | [
"Sets",
"the",
"ReadListener",
"provided",
"by",
"the",
"application",
"to",
"this",
"stream",
"Once",
"the",
"ReadListener",
"is",
"set",
"we",
"will",
"kick",
"off",
"the",
"initial",
"read"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java#L362-L394 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java | UpgradeInputByteBufferUtil.initialRead | public void initialRead(){
_isInitialRead = true;
if(_buffer != null){
_buffer.release();
_buffer = null;
}
setAndAllocateBuffer(1);
configurePreReadBuffer(1);
//This if the first read of the ReadListener, which means force the read to go async
//We won't get an actual response from this read as it will always come back on another thread
_tcpContext.getReadInterface().setBuffer(_buffer);
_tcpContext.getReadInterface().read(1, _tcpChannelCallback, true, WCCustomProperties31.UPGRADE_READ_TIMEOUT);
} | java | public void initialRead(){
_isInitialRead = true;
if(_buffer != null){
_buffer.release();
_buffer = null;
}
setAndAllocateBuffer(1);
configurePreReadBuffer(1);
//This if the first read of the ReadListener, which means force the read to go async
//We won't get an actual response from this read as it will always come back on another thread
_tcpContext.getReadInterface().setBuffer(_buffer);
_tcpContext.getReadInterface().read(1, _tcpChannelCallback, true, WCCustomProperties31.UPGRADE_READ_TIMEOUT);
} | [
"public",
"void",
"initialRead",
"(",
")",
"{",
"_isInitialRead",
"=",
"true",
";",
"if",
"(",
"_buffer",
"!=",
"null",
")",
"{",
"_buffer",
".",
"release",
"(",
")",
";",
"_buffer",
"=",
"null",
";",
"}",
"setAndAllocateBuffer",
"(",
"1",
")",
";",
"configurePreReadBuffer",
"(",
"1",
")",
";",
"//This if the first read of the ReadListener, which means force the read to go async",
"//We won't get an actual response from this read as it will always come back on another thread",
"_tcpContext",
".",
"getReadInterface",
"(",
")",
".",
"setBuffer",
"(",
"_buffer",
")",
";",
"_tcpContext",
".",
"getReadInterface",
"(",
")",
".",
"read",
"(",
"1",
",",
"_tcpChannelCallback",
",",
"true",
",",
"WCCustomProperties31",
".",
"UPGRADE_READ_TIMEOUT",
")",
";",
"}"
] | This method triggers the initial read on the connection, or the read for after the ReadListener.onDataAvailable has run
The read done in this method is a forced async read, meaning it will always return on another thread
The provided callback will be called when the read is completed and that callback will invoke the ReadListener logic. | [
"This",
"method",
"triggers",
"the",
"initial",
"read",
"on",
"the",
"connection",
"or",
"the",
"read",
"for",
"after",
"the",
"ReadListener",
".",
"onDataAvailable",
"has",
"run",
"The",
"read",
"done",
"in",
"this",
"method",
"is",
"a",
"forced",
"async",
"read",
"meaning",
"it",
"will",
"always",
"return",
"on",
"another",
"thread",
"The",
"provided",
"callback",
"will",
"be",
"called",
"when",
"the",
"read",
"is",
"completed",
"and",
"that",
"callback",
"will",
"invoke",
"the",
"ReadListener",
"logic",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java#L469-L483 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java | UpgradeInputByteBufferUtil.configurePostInitialReadBuffer | public void configurePostInitialReadBuffer(){
_isInitialRead = false;
_isFirstRead = false;
_buffer = _tcpContext.getReadInterface().getBuffer();
configurePostReadBuffer();
} | java | public void configurePostInitialReadBuffer(){
_isInitialRead = false;
_isFirstRead = false;
_buffer = _tcpContext.getReadInterface().getBuffer();
configurePostReadBuffer();
} | [
"public",
"void",
"configurePostInitialReadBuffer",
"(",
")",
"{",
"_isInitialRead",
"=",
"false",
";",
"_isFirstRead",
"=",
"false",
";",
"_buffer",
"=",
"_tcpContext",
".",
"getReadInterface",
"(",
")",
".",
"getBuffer",
"(",
")",
";",
"configurePostReadBuffer",
"(",
")",
";",
"}"
] | Called after the initial read is completed. This will set the first read flag to false, get the buffer from the TCP Channel,
and post configure the buffer. Without this method we would lose the first byte we are reading | [
"Called",
"after",
"the",
"initial",
"read",
"is",
"completed",
".",
"This",
"will",
"set",
"the",
"first",
"read",
"flag",
"to",
"false",
"get",
"the",
"buffer",
"from",
"the",
"TCP",
"Channel",
"and",
"post",
"configure",
"the",
"buffer",
".",
"Without",
"this",
"method",
"we",
"would",
"lose",
"the",
"first",
"byte",
"we",
"are",
"reading"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java#L489-L494 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java | UpgradeInputByteBufferUtil.close | public Boolean close() {
_isClosing = true;
boolean closeResult = true;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "close, Initial read outstanding : " + _isInitialRead);
}
if(_isInitialRead){
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "close, Cancelling any outstanding read");
}
_tcpContext.getReadInterface().read(1, _tcpChannelCallback, false, TCPReadRequestContext.IMMED_TIMEOUT);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "close, Call to cancel complete");
}
//This seems strange, but what happens during the timeout it will be set to false.
//If it's false we don't want to do the wait since it's been called in line.
//If it's true we will want to wait until the timeout has been processed
if(_isInitialRead){
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "close, Timeout has been called, waiting for it to complete");
}
closeResult = true;
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "close, No read outstanding, no reason to call cancel");
}
closeResult = false;
}
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "close, No read outstanding, no reason to call cancel");
}
closeResult = false;
}
if(_rl != null){
if(!this.isAlldataReadCalled()) {
try {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "close, We are now closed, calling the ReadListener onAllDataRead");
}
this.setAlldataReadCalled(true);
_rl.onAllDataRead();
} catch (IOException ioe) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "close, Encountered an exception while calling onAllDAtaRead : " + ioe);
}
}
}
}
return closeResult;
} | java | public Boolean close() {
_isClosing = true;
boolean closeResult = true;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "close, Initial read outstanding : " + _isInitialRead);
}
if(_isInitialRead){
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "close, Cancelling any outstanding read");
}
_tcpContext.getReadInterface().read(1, _tcpChannelCallback, false, TCPReadRequestContext.IMMED_TIMEOUT);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "close, Call to cancel complete");
}
//This seems strange, but what happens during the timeout it will be set to false.
//If it's false we don't want to do the wait since it's been called in line.
//If it's true we will want to wait until the timeout has been processed
if(_isInitialRead){
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "close, Timeout has been called, waiting for it to complete");
}
closeResult = true;
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "close, No read outstanding, no reason to call cancel");
}
closeResult = false;
}
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "close, No read outstanding, no reason to call cancel");
}
closeResult = false;
}
if(_rl != null){
if(!this.isAlldataReadCalled()) {
try {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "close, We are now closed, calling the ReadListener onAllDataRead");
}
this.setAlldataReadCalled(true);
_rl.onAllDataRead();
} catch (IOException ioe) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
Tr.debug(tc, "close, Encountered an exception while calling onAllDAtaRead : " + ioe);
}
}
}
}
return closeResult;
} | [
"public",
"Boolean",
"close",
"(",
")",
"{",
"_isClosing",
"=",
"true",
";",
"boolean",
"closeResult",
"=",
"true",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"close, Initial read outstanding : \"",
"+",
"_isInitialRead",
")",
";",
"}",
"if",
"(",
"_isInitialRead",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"close, Cancelling any outstanding read\"",
")",
";",
"}",
"_tcpContext",
".",
"getReadInterface",
"(",
")",
".",
"read",
"(",
"1",
",",
"_tcpChannelCallback",
",",
"false",
",",
"TCPReadRequestContext",
".",
"IMMED_TIMEOUT",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"close, Call to cancel complete\"",
")",
";",
"}",
"//This seems strange, but what happens during the timeout it will be set to false.",
"//If it's false we don't want to do the wait since it's been called in line.",
"//If it's true we will want to wait until the timeout has been processed",
"if",
"(",
"_isInitialRead",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"close, Timeout has been called, waiting for it to complete\"",
")",
";",
"}",
"closeResult",
"=",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"close, No read outstanding, no reason to call cancel\"",
")",
";",
"}",
"closeResult",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"close, No read outstanding, no reason to call cancel\"",
")",
";",
"}",
"closeResult",
"=",
"false",
";",
"}",
"if",
"(",
"_rl",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isAlldataReadCalled",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"close, We are now closed, calling the ReadListener onAllDataRead\"",
")",
";",
"}",
"this",
".",
"setAlldataReadCalled",
"(",
"true",
")",
";",
"_rl",
".",
"onAllDataRead",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"close, Encountered an exception while calling onAllDAtaRead : \"",
"+",
"ioe",
")",
";",
"}",
"}",
"}",
"}",
"return",
"closeResult",
";",
"}"
] | Close the connection down by immediately timing out any existing read | [
"Close",
"the",
"connection",
"down",
"by",
"immediately",
"timing",
"out",
"any",
"existing",
"read"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java#L521-L578 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/indexes/SubscriptionIndex.java | SubscriptionIndex.getDurableSubscriptions | public synchronized int getDurableSubscriptions()
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "getDurableSubscriptions");
if (tc.isEntryEnabled())
SibTr.exit(
tc,
"getDurableSubscriptions",
new Integer(durableSubscriptions));
return durableSubscriptions;
} | java | public synchronized int getDurableSubscriptions()
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "getDurableSubscriptions");
if (tc.isEntryEnabled())
SibTr.exit(
tc,
"getDurableSubscriptions",
new Integer(durableSubscriptions));
return durableSubscriptions;
} | [
"public",
"synchronized",
"int",
"getDurableSubscriptions",
"(",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"getDurableSubscriptions\"",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"getDurableSubscriptions\"",
",",
"new",
"Integer",
"(",
"durableSubscriptions",
")",
")",
";",
"return",
"durableSubscriptions",
";",
"}"
] | Get number of durable subscriptions.
@return number of durable subscriptions. | [
"Get",
"number",
"of",
"durable",
"subscriptions",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/indexes/SubscriptionIndex.java#L149-L161 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/indexes/SubscriptionIndex.java | SubscriptionIndex.getNonDurableSubscriptions | public synchronized int getNonDurableSubscriptions()
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "getNonDurableSubscriptions");
if (tc.isEntryEnabled())
SibTr.exit(
tc,
"getNonDurableSubscriptions",
new Integer(nonDurableSubscriptions));
return nonDurableSubscriptions;
} | java | public synchronized int getNonDurableSubscriptions()
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "getNonDurableSubscriptions");
if (tc.isEntryEnabled())
SibTr.exit(
tc,
"getNonDurableSubscriptions",
new Integer(nonDurableSubscriptions));
return nonDurableSubscriptions;
} | [
"public",
"synchronized",
"int",
"getNonDurableSubscriptions",
"(",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"getNonDurableSubscriptions\"",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"getNonDurableSubscriptions\"",
",",
"new",
"Integer",
"(",
"nonDurableSubscriptions",
")",
")",
";",
"return",
"nonDurableSubscriptions",
";",
"}"
] | Get number of non-durable subscriptions.
@return number of non-durable subscriptions. | [
"Get",
"number",
"of",
"non",
"-",
"durable",
"subscriptions",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/indexes/SubscriptionIndex.java#L168-L180 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/indexes/SubscriptionIndex.java | SubscriptionIndex.getTotalSubscriptions | public synchronized int getTotalSubscriptions()
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "getTotalSubscriptions");
int totalSubscriptions = durableSubscriptions + nonDurableSubscriptions;
if (tc.isEntryEnabled())
SibTr.exit(
tc,
"getTotalSubscriptions",
new Integer(totalSubscriptions));
return totalSubscriptions;
} | java | public synchronized int getTotalSubscriptions()
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "getTotalSubscriptions");
int totalSubscriptions = durableSubscriptions + nonDurableSubscriptions;
if (tc.isEntryEnabled())
SibTr.exit(
tc,
"getTotalSubscriptions",
new Integer(totalSubscriptions));
return totalSubscriptions;
} | [
"public",
"synchronized",
"int",
"getTotalSubscriptions",
"(",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"getTotalSubscriptions\"",
")",
";",
"int",
"totalSubscriptions",
"=",
"durableSubscriptions",
"+",
"nonDurableSubscriptions",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"getTotalSubscriptions\"",
",",
"new",
"Integer",
"(",
"totalSubscriptions",
")",
")",
";",
"return",
"totalSubscriptions",
";",
"}"
] | Get total number of subscriptions.
@return total number of subscriptions. | [
"Get",
"total",
"number",
"of",
"subscriptions",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/indexes/SubscriptionIndex.java#L187-L201 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSInsertHeight.java | GBSInsertHeight.balance | void balance(
NodeStack stack,
GBSNode q)
{
GBSNode p;
int bpidx = stack.balancePointIndex();
int x = bpidx;
GBSNode bpoint = stack.node(x);
GBSNode bfather = stack.node(x-1);
/* Adjust balance factors in intervening nodes */
if (bpoint.leftChild() == stack.node(x+1))
p = bpoint.leftChild();
else
p = bpoint.rightChild();
x++;
while (p != q)
{
if (p.leftChild() == stack.node(x+1))
{ /* We followed and added to left path */
p.setBalance(-1); /* It is now left heavy */
p = p.leftChild();
}
else /* We followed and added to right path */
{
p.setBalance(1); /* It is now right heavy */
p = p.rightChild();
}
x++;
}
/* Adjust the balance factor at the balance point. */
/* Re-balance if necessary. */
if (bpoint.leftChild() == stack.node(bpidx+1))
{ /* Added to left side */
int bpb = bpoint.balance();
switch (bpb)
{
case 0:
bpoint.setBalance(-1);
break;
case 1:
bpoint.clearBalance();
break;
case -1:
rotateLeft(bfather, bpoint);
break;
default:
String zzz1 = "Help1 !, bpb = " + bpb;
throw new RuntimeException(zzz1);
}
}
else /* Added to right side */
{
int bpb = bpoint.balance();
switch (bpb)
{
case 0:
bpoint.setBalance(1);
break;
case -1:
bpoint.clearBalance();
break;
case 1:
rotateRight(bfather, bpoint);
break;
default:
String zzz2 = "Help2 !, bpb = " + bpb;
throw new RuntimeException(zzz2);
}
}
} | java | void balance(
NodeStack stack,
GBSNode q)
{
GBSNode p;
int bpidx = stack.balancePointIndex();
int x = bpidx;
GBSNode bpoint = stack.node(x);
GBSNode bfather = stack.node(x-1);
/* Adjust balance factors in intervening nodes */
if (bpoint.leftChild() == stack.node(x+1))
p = bpoint.leftChild();
else
p = bpoint.rightChild();
x++;
while (p != q)
{
if (p.leftChild() == stack.node(x+1))
{ /* We followed and added to left path */
p.setBalance(-1); /* It is now left heavy */
p = p.leftChild();
}
else /* We followed and added to right path */
{
p.setBalance(1); /* It is now right heavy */
p = p.rightChild();
}
x++;
}
/* Adjust the balance factor at the balance point. */
/* Re-balance if necessary. */
if (bpoint.leftChild() == stack.node(bpidx+1))
{ /* Added to left side */
int bpb = bpoint.balance();
switch (bpb)
{
case 0:
bpoint.setBalance(-1);
break;
case 1:
bpoint.clearBalance();
break;
case -1:
rotateLeft(bfather, bpoint);
break;
default:
String zzz1 = "Help1 !, bpb = " + bpb;
throw new RuntimeException(zzz1);
}
}
else /* Added to right side */
{
int bpb = bpoint.balance();
switch (bpb)
{
case 0:
bpoint.setBalance(1);
break;
case -1:
bpoint.clearBalance();
break;
case 1:
rotateRight(bfather, bpoint);
break;
default:
String zzz2 = "Help2 !, bpb = " + bpb;
throw new RuntimeException(zzz2);
}
}
} | [
"void",
"balance",
"(",
"NodeStack",
"stack",
",",
"GBSNode",
"q",
")",
"{",
"GBSNode",
"p",
";",
"int",
"bpidx",
"=",
"stack",
".",
"balancePointIndex",
"(",
")",
";",
"int",
"x",
"=",
"bpidx",
";",
"GBSNode",
"bpoint",
"=",
"stack",
".",
"node",
"(",
"x",
")",
";",
"GBSNode",
"bfather",
"=",
"stack",
".",
"node",
"(",
"x",
"-",
"1",
")",
";",
"/* Adjust balance factors in intervening nodes */",
"if",
"(",
"bpoint",
".",
"leftChild",
"(",
")",
"==",
"stack",
".",
"node",
"(",
"x",
"+",
"1",
")",
")",
"p",
"=",
"bpoint",
".",
"leftChild",
"(",
")",
";",
"else",
"p",
"=",
"bpoint",
".",
"rightChild",
"(",
")",
";",
"x",
"++",
";",
"while",
"(",
"p",
"!=",
"q",
")",
"{",
"if",
"(",
"p",
".",
"leftChild",
"(",
")",
"==",
"stack",
".",
"node",
"(",
"x",
"+",
"1",
")",
")",
"{",
"/* We followed and added to left path */",
"p",
".",
"setBalance",
"(",
"-",
"1",
")",
";",
"/* It is now left heavy */",
"p",
"=",
"p",
".",
"leftChild",
"(",
")",
";",
"}",
"else",
"/* We followed and added to right path */",
"{",
"p",
".",
"setBalance",
"(",
"1",
")",
";",
"/* It is now right heavy */",
"p",
"=",
"p",
".",
"rightChild",
"(",
")",
";",
"}",
"x",
"++",
";",
"}",
"/* Adjust the balance factor at the balance point. */",
"/* Re-balance if necessary. */",
"if",
"(",
"bpoint",
".",
"leftChild",
"(",
")",
"==",
"stack",
".",
"node",
"(",
"bpidx",
"+",
"1",
")",
")",
"{",
"/* Added to left side */",
"int",
"bpb",
"=",
"bpoint",
".",
"balance",
"(",
")",
";",
"switch",
"(",
"bpb",
")",
"{",
"case",
"0",
":",
"bpoint",
".",
"setBalance",
"(",
"-",
"1",
")",
";",
"break",
";",
"case",
"1",
":",
"bpoint",
".",
"clearBalance",
"(",
")",
";",
"break",
";",
"case",
"-",
"1",
":",
"rotateLeft",
"(",
"bfather",
",",
"bpoint",
")",
";",
"break",
";",
"default",
":",
"String",
"zzz1",
"=",
"\"Help1 !, bpb = \"",
"+",
"bpb",
";",
"throw",
"new",
"RuntimeException",
"(",
"zzz1",
")",
";",
"}",
"}",
"else",
"/* Added to right side */",
"{",
"int",
"bpb",
"=",
"bpoint",
".",
"balance",
"(",
")",
";",
"switch",
"(",
"bpb",
")",
"{",
"case",
"0",
":",
"bpoint",
".",
"setBalance",
"(",
"1",
")",
";",
"break",
";",
"case",
"-",
"1",
":",
"bpoint",
".",
"clearBalance",
"(",
")",
";",
"break",
";",
"case",
"1",
":",
"rotateRight",
"(",
"bfather",
",",
"bpoint",
")",
";",
"break",
";",
"default",
":",
"String",
"zzz2",
"=",
"\"Help2 !, bpb = \"",
"+",
"bpb",
";",
"throw",
"new",
"RuntimeException",
"(",
"zzz2",
")",
";",
"}",
"}",
"}"
] | Restore the height balance of a tree following an insert.
@param stack The NodeStack used to do the insert.
@param q The root of the newly added fringe. | [
"Restore",
"the",
"height",
"balance",
"of",
"a",
"tree",
"following",
"an",
"insert",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSInsertHeight.java#L212-L283 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSInsertHeight.java | GBSInsertHeight.rotateLeft | private void rotateLeft(
GBSNode bfather,
GBSNode bpoint)
{
GBSNode bson = bpoint.leftChild();
if (bson.balance() == -1) /* Single LL rotation */
{
bpoint.setLeftChild(bson.rightChild());
bson.setRightChild(bpoint);
if (bfather.rightChild() == bpoint)
bfather.setRightChild(bson);
else
bfather.setLeftChild(bson);
bpoint.clearBalance();
bson.clearBalance();
}
else /* Double LR rotation */
{
GBSNode blift = bson.rightChild();
bson.setRightChild(blift.leftChild());
blift.setLeftChild(bson);
bpoint.setLeftChild(blift.rightChild());
blift.setRightChild(bpoint);
if (bfather.rightChild() == bpoint)
bfather.setRightChild(blift);
else
bfather.setLeftChild(blift);
bpoint.setBalance(newBalance2[blift.balance()+1]);
bson.setBalance( newBalance1[blift.balance()+1]);
blift.clearBalance();
}
} | java | private void rotateLeft(
GBSNode bfather,
GBSNode bpoint)
{
GBSNode bson = bpoint.leftChild();
if (bson.balance() == -1) /* Single LL rotation */
{
bpoint.setLeftChild(bson.rightChild());
bson.setRightChild(bpoint);
if (bfather.rightChild() == bpoint)
bfather.setRightChild(bson);
else
bfather.setLeftChild(bson);
bpoint.clearBalance();
bson.clearBalance();
}
else /* Double LR rotation */
{
GBSNode blift = bson.rightChild();
bson.setRightChild(blift.leftChild());
blift.setLeftChild(bson);
bpoint.setLeftChild(blift.rightChild());
blift.setRightChild(bpoint);
if (bfather.rightChild() == bpoint)
bfather.setRightChild(blift);
else
bfather.setLeftChild(blift);
bpoint.setBalance(newBalance2[blift.balance()+1]);
bson.setBalance( newBalance1[blift.balance()+1]);
blift.clearBalance();
}
} | [
"private",
"void",
"rotateLeft",
"(",
"GBSNode",
"bfather",
",",
"GBSNode",
"bpoint",
")",
"{",
"GBSNode",
"bson",
"=",
"bpoint",
".",
"leftChild",
"(",
")",
";",
"if",
"(",
"bson",
".",
"balance",
"(",
")",
"==",
"-",
"1",
")",
"/* Single LL rotation */",
"{",
"bpoint",
".",
"setLeftChild",
"(",
"bson",
".",
"rightChild",
"(",
")",
")",
";",
"bson",
".",
"setRightChild",
"(",
"bpoint",
")",
";",
"if",
"(",
"bfather",
".",
"rightChild",
"(",
")",
"==",
"bpoint",
")",
"bfather",
".",
"setRightChild",
"(",
"bson",
")",
";",
"else",
"bfather",
".",
"setLeftChild",
"(",
"bson",
")",
";",
"bpoint",
".",
"clearBalance",
"(",
")",
";",
"bson",
".",
"clearBalance",
"(",
")",
";",
"}",
"else",
"/* Double LR rotation */",
"{",
"GBSNode",
"blift",
"=",
"bson",
".",
"rightChild",
"(",
")",
";",
"bson",
".",
"setRightChild",
"(",
"blift",
".",
"leftChild",
"(",
")",
")",
";",
"blift",
".",
"setLeftChild",
"(",
"bson",
")",
";",
"bpoint",
".",
"setLeftChild",
"(",
"blift",
".",
"rightChild",
"(",
")",
")",
";",
"blift",
".",
"setRightChild",
"(",
"bpoint",
")",
";",
"if",
"(",
"bfather",
".",
"rightChild",
"(",
")",
"==",
"bpoint",
")",
"bfather",
".",
"setRightChild",
"(",
"blift",
")",
";",
"else",
"bfather",
".",
"setLeftChild",
"(",
"blift",
")",
";",
"bpoint",
".",
"setBalance",
"(",
"newBalance2",
"[",
"blift",
".",
"balance",
"(",
")",
"+",
"1",
"]",
")",
";",
"bson",
".",
"setBalance",
"(",
"newBalance1",
"[",
"blift",
".",
"balance",
"(",
")",
"+",
"1",
"]",
")",
";",
"blift",
".",
"clearBalance",
"(",
")",
";",
"}",
"}"
] | Do an LL or LR rotation.
@param bfather The father of the balance point.
@param bpoint The balance point. | [
"Do",
"an",
"LL",
"or",
"LR",
"rotation",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSInsertHeight.java#L291-L322 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/utils/linkedlist/Entry.java | Entry.getPrevious | public Entry getPrevious()
{
checkEntryParent();
Entry entry = null;
if(!isFirst())
{
entry = previous;
}
return entry;
} | java | public Entry getPrevious()
{
checkEntryParent();
Entry entry = null;
if(!isFirst())
{
entry = previous;
}
return entry;
} | [
"public",
"Entry",
"getPrevious",
"(",
")",
"{",
"checkEntryParent",
"(",
")",
";",
"Entry",
"entry",
"=",
"null",
";",
"if",
"(",
"!",
"isFirst",
"(",
")",
")",
"{",
"entry",
"=",
"previous",
";",
"}",
"return",
"entry",
";",
"}"
] | Unsynchronized. Get the previous entry in the list.
@return the previous entry in the list | [
"Unsynchronized",
".",
"Get",
"the",
"previous",
"entry",
"in",
"the",
"list",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/utils/linkedlist/Entry.java#L53-L65 | train |
OpenLiberty/open-liberty | dev/wlp-bndPlugins/src/com/ibm/ws/build/bnd/plugins/ImportlessPackager.java | ImportlessPackager.analyzeJar | @Override
public boolean analyzeJar(Analyzer analyzer) throws Exception {
try {
if (scanAgain) {
//this will only have an effect on the first scan, because subsequent scanAgain
//will use the errorMarker to decide if to scan again
resetErrorMarker();
List<String> newlyAddedPackages = new ArrayList<String>();
System.out.println("ImportlessPackager plugin: iteration " + iteration);
// set up exclude filter
setupFilters(analyzer);
// collect dependency packages
Set<PackageRef> importedPackages = collectDependencies(analyzer);
Jar outputJar = analyzer.getJar();
//loop through the referred packages
for (PackageRef ref : importedPackages) {
String packageName = ref.getFQN();
System.out.println("Seeking package " + packageName);
boolean foundPackage = false;
// locate the package in the classpath and add it the the export
for (Jar src : analyzer.getClasspath()) {
if (src.getPackages().contains(packageName)) {
foundPackage = true;
System.out.println("Found matching pkg " + packageName + " from " +src.getSource().getAbsolutePath());
//only want to include the package itself, not any sub-packages
//can provide an Instruction to bnd for this, but it gets a bit weird:
//match the package name plus a / since everything in the package will
//have the package path followed by a separator.
//We use [/|/] to match the single / because bnd needs something to serve
//as a wildcard to enable regex matching (otherwise it just does an equals match)
//we can't use the other wildcards e.g. * ? because bnd processes them into
//.?, .* to do an any character match
//If we don't want any sub package content we can't allow any more slashes
//so use [^/]+ (i.e. not / 1 or more times)
outputJar.addAll(src, new Instruction(ref.getPath() + "[/|/][^/]+"));
newlyAddedPackages.add(packageName);
//we don't break the outer loop in case of split packages (ick!)
//since we might find some additional content for this package in another jar
}
}
if (!foundPackage) {
//we couldn't find the package on the classpath, fail the build
//with a helpful message
String errorMsg = "Package " + packageName + " not found for inclusion in jar. Is the package available on the projects classpath?";
error(errorMsg);
}
}
//add all the newly added packages to our global list so we don't check them again
if (newlyAddedPackages.isEmpty()) {
//no new packages, no further scanning required
scanAgain = false;
} else {
addedPackages.addAll(newlyAddedPackages);
iteration++;
if (iteration > LAST_ITERATION) {
//there are new packages but we've run out of iterations, fail the build
error("Maximum number of plugin iterations reached, but there were still new packages to analyze. Consider adding more iterations.");
}
}
//don't bother scanning again if we've already had an error
if (scanAgain == true && errorMarker.exists())
scanAgain = false;
}
} catch(Exception ex) {
ex.printStackTrace();
System.out.println(ex.getMessage());
}
//tell bnd to reanalyze the classpath if we are going to scan again
return scanAgain;
} | java | @Override
public boolean analyzeJar(Analyzer analyzer) throws Exception {
try {
if (scanAgain) {
//this will only have an effect on the first scan, because subsequent scanAgain
//will use the errorMarker to decide if to scan again
resetErrorMarker();
List<String> newlyAddedPackages = new ArrayList<String>();
System.out.println("ImportlessPackager plugin: iteration " + iteration);
// set up exclude filter
setupFilters(analyzer);
// collect dependency packages
Set<PackageRef> importedPackages = collectDependencies(analyzer);
Jar outputJar = analyzer.getJar();
//loop through the referred packages
for (PackageRef ref : importedPackages) {
String packageName = ref.getFQN();
System.out.println("Seeking package " + packageName);
boolean foundPackage = false;
// locate the package in the classpath and add it the the export
for (Jar src : analyzer.getClasspath()) {
if (src.getPackages().contains(packageName)) {
foundPackage = true;
System.out.println("Found matching pkg " + packageName + " from " +src.getSource().getAbsolutePath());
//only want to include the package itself, not any sub-packages
//can provide an Instruction to bnd for this, but it gets a bit weird:
//match the package name plus a / since everything in the package will
//have the package path followed by a separator.
//We use [/|/] to match the single / because bnd needs something to serve
//as a wildcard to enable regex matching (otherwise it just does an equals match)
//we can't use the other wildcards e.g. * ? because bnd processes them into
//.?, .* to do an any character match
//If we don't want any sub package content we can't allow any more slashes
//so use [^/]+ (i.e. not / 1 or more times)
outputJar.addAll(src, new Instruction(ref.getPath() + "[/|/][^/]+"));
newlyAddedPackages.add(packageName);
//we don't break the outer loop in case of split packages (ick!)
//since we might find some additional content for this package in another jar
}
}
if (!foundPackage) {
//we couldn't find the package on the classpath, fail the build
//with a helpful message
String errorMsg = "Package " + packageName + " not found for inclusion in jar. Is the package available on the projects classpath?";
error(errorMsg);
}
}
//add all the newly added packages to our global list so we don't check them again
if (newlyAddedPackages.isEmpty()) {
//no new packages, no further scanning required
scanAgain = false;
} else {
addedPackages.addAll(newlyAddedPackages);
iteration++;
if (iteration > LAST_ITERATION) {
//there are new packages but we've run out of iterations, fail the build
error("Maximum number of plugin iterations reached, but there were still new packages to analyze. Consider adding more iterations.");
}
}
//don't bother scanning again if we've already had an error
if (scanAgain == true && errorMarker.exists())
scanAgain = false;
}
} catch(Exception ex) {
ex.printStackTrace();
System.out.println(ex.getMessage());
}
//tell bnd to reanalyze the classpath if we are going to scan again
return scanAgain;
} | [
"@",
"Override",
"public",
"boolean",
"analyzeJar",
"(",
"Analyzer",
"analyzer",
")",
"throws",
"Exception",
"{",
"try",
"{",
"if",
"(",
"scanAgain",
")",
"{",
"//this will only have an effect on the first scan, because subsequent scanAgain",
"//will use the errorMarker to decide if to scan again",
"resetErrorMarker",
"(",
")",
";",
"List",
"<",
"String",
">",
"newlyAddedPackages",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"ImportlessPackager plugin: iteration \"",
"+",
"iteration",
")",
";",
"// set up exclude filter",
"setupFilters",
"(",
"analyzer",
")",
";",
"// collect dependency packages",
"Set",
"<",
"PackageRef",
">",
"importedPackages",
"=",
"collectDependencies",
"(",
"analyzer",
")",
";",
"Jar",
"outputJar",
"=",
"analyzer",
".",
"getJar",
"(",
")",
";",
"//loop through the referred packages",
"for",
"(",
"PackageRef",
"ref",
":",
"importedPackages",
")",
"{",
"String",
"packageName",
"=",
"ref",
".",
"getFQN",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Seeking package \"",
"+",
"packageName",
")",
";",
"boolean",
"foundPackage",
"=",
"false",
";",
"// locate the package in the classpath and add it the the export",
"for",
"(",
"Jar",
"src",
":",
"analyzer",
".",
"getClasspath",
"(",
")",
")",
"{",
"if",
"(",
"src",
".",
"getPackages",
"(",
")",
".",
"contains",
"(",
"packageName",
")",
")",
"{",
"foundPackage",
"=",
"true",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Found matching pkg \"",
"+",
"packageName",
"+",
"\" from \"",
"+",
"src",
".",
"getSource",
"(",
")",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"//only want to include the package itself, not any sub-packages",
"//can provide an Instruction to bnd for this, but it gets a bit weird:",
"//match the package name plus a / since everything in the package will",
"//have the package path followed by a separator.",
"//We use [/|/] to match the single / because bnd needs something to serve",
"//as a wildcard to enable regex matching (otherwise it just does an equals match)",
"//we can't use the other wildcards e.g. * ? because bnd processes them into",
"//.?, .* to do an any character match",
"//If we don't want any sub package content we can't allow any more slashes",
"//so use [^/]+ (i.e. not / 1 or more times)",
"outputJar",
".",
"addAll",
"(",
"src",
",",
"new",
"Instruction",
"(",
"ref",
".",
"getPath",
"(",
")",
"+",
"\"[/|/][^/]+\"",
")",
")",
";",
"newlyAddedPackages",
".",
"add",
"(",
"packageName",
")",
";",
"//we don't break the outer loop in case of split packages (ick!)",
"//since we might find some additional content for this package in another jar",
"}",
"}",
"if",
"(",
"!",
"foundPackage",
")",
"{",
"//we couldn't find the package on the classpath, fail the build",
"//with a helpful message",
"String",
"errorMsg",
"=",
"\"Package \"",
"+",
"packageName",
"+",
"\" not found for inclusion in jar. Is the package available on the projects classpath?\"",
";",
"error",
"(",
"errorMsg",
")",
";",
"}",
"}",
"//add all the newly added packages to our global list so we don't check them again",
"if",
"(",
"newlyAddedPackages",
".",
"isEmpty",
"(",
")",
")",
"{",
"//no new packages, no further scanning required",
"scanAgain",
"=",
"false",
";",
"}",
"else",
"{",
"addedPackages",
".",
"addAll",
"(",
"newlyAddedPackages",
")",
";",
"iteration",
"++",
";",
"if",
"(",
"iteration",
">",
"LAST_ITERATION",
")",
"{",
"//there are new packages but we've run out of iterations, fail the build",
"error",
"(",
"\"Maximum number of plugin iterations reached, but there were still new packages to analyze. Consider adding more iterations.\"",
")",
";",
"}",
"}",
"//don't bother scanning again if we've already had an error",
"if",
"(",
"scanAgain",
"==",
"true",
"&&",
"errorMarker",
".",
"exists",
"(",
")",
")",
"scanAgain",
"=",
"false",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"//tell bnd to reanalyze the classpath if we are going to scan again",
"return",
"scanAgain",
";",
"}"
] | all class types that need to be exported | [
"all",
"class",
"types",
"that",
"need",
"to",
"be",
"exported"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/wlp-bndPlugins/src/com/ibm/ws/build/bnd/plugins/ImportlessPackager.java#L34-L118 | train |
OpenLiberty/open-liberty | dev/wlp-bndPlugins/src/com/ibm/ws/build/bnd/plugins/ImportlessPackager.java | ImportlessPackager.collectClassDependencies | private void collectClassDependencies (Clazz classInstance, Analyzer analyzer) throws Exception {
// retrieve the imports from the known class path
Set<TypeRef> importedClasses = classInstance.parseClassFile();
for (TypeRef importedClass:importedClasses) {
if (canBeSkipped(importedClass)) // validate the import
continue;
// find the class in the classpath
Clazz classInstanceImported = analyzer.findClass(importedClass);
if (classInstanceImported == null)
error( "Referenced class " + importedClass.getFQN() + " not found for inclusion in jar. It is imported by " + classInstance.getAbsolutePath());
// update the imports map
importedReferencedTypes.add(importedClass);
allReferencedTypes.add(importedClass);
// collect dependencies introduced by the imports
collectClassDependencies(classInstanceImported, analyzer);
}
} | java | private void collectClassDependencies (Clazz classInstance, Analyzer analyzer) throws Exception {
// retrieve the imports from the known class path
Set<TypeRef> importedClasses = classInstance.parseClassFile();
for (TypeRef importedClass:importedClasses) {
if (canBeSkipped(importedClass)) // validate the import
continue;
// find the class in the classpath
Clazz classInstanceImported = analyzer.findClass(importedClass);
if (classInstanceImported == null)
error( "Referenced class " + importedClass.getFQN() + " not found for inclusion in jar. It is imported by " + classInstance.getAbsolutePath());
// update the imports map
importedReferencedTypes.add(importedClass);
allReferencedTypes.add(importedClass);
// collect dependencies introduced by the imports
collectClassDependencies(classInstanceImported, analyzer);
}
} | [
"private",
"void",
"collectClassDependencies",
"(",
"Clazz",
"classInstance",
",",
"Analyzer",
"analyzer",
")",
"throws",
"Exception",
"{",
"// retrieve the imports from the known class path",
"Set",
"<",
"TypeRef",
">",
"importedClasses",
"=",
"classInstance",
".",
"parseClassFile",
"(",
")",
";",
"for",
"(",
"TypeRef",
"importedClass",
":",
"importedClasses",
")",
"{",
"if",
"(",
"canBeSkipped",
"(",
"importedClass",
")",
")",
"// validate the import",
"continue",
";",
"// find the class in the classpath",
"Clazz",
"classInstanceImported",
"=",
"analyzer",
".",
"findClass",
"(",
"importedClass",
")",
";",
"if",
"(",
"classInstanceImported",
"==",
"null",
")",
"error",
"(",
"\"Referenced class \"",
"+",
"importedClass",
".",
"getFQN",
"(",
")",
"+",
"\" not found for inclusion in jar. It is imported by \"",
"+",
"classInstance",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"// update the imports map",
"importedReferencedTypes",
".",
"add",
"(",
"importedClass",
")",
";",
"allReferencedTypes",
".",
"add",
"(",
"importedClass",
")",
";",
"// collect dependencies introduced by the imports",
"collectClassDependencies",
"(",
"classInstanceImported",
",",
"analyzer",
")",
";",
"}",
"}"
] | Collect the imports from a class and add the imported classes to the map of all known classes
importedReferencedTypes is updated to contain newly added imports
allReferencedTypes is updated to avoid the duplicated process
@param classInstance
@param analyzer
@throws Exception | [
"Collect",
"the",
"imports",
"from",
"a",
"class",
"and",
"add",
"the",
"imported",
"classes",
"to",
"the",
"map",
"of",
"all",
"known",
"classes",
"importedReferencedTypes",
"is",
"updated",
"to",
"contain",
"newly",
"added",
"imports",
"allReferencedTypes",
"is",
"updated",
"to",
"avoid",
"the",
"duplicated",
"process"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/wlp-bndPlugins/src/com/ibm/ws/build/bnd/plugins/ImportlessPackager.java#L239-L256 | train |
OpenLiberty/open-liberty | dev/wlp-bndPlugins/src/com/ibm/ws/build/bnd/plugins/ImportlessPackager.java | ImportlessPackager.canBeSkipped | private boolean canBeSkipped (TypeRef importedClass) {
// skip known imported classes and the ones in JRE
if (allReferencedTypes.contains(importedClass) || importedReferencedTypes.contains(importedClass) || importedClass.isJava())
return true;
// Skip the imported classes which are excluded
String classPackage = importedClass.getPackageRef().getFQN();
for (String excludePrefix: excludePrefixes) { // skip by the package prefix
if (classPackage.startsWith(excludePrefix))
return true;
}
if (excludes.contains(classPackage)) // skip by the full package name
return true;
return classPackage.length()<2; // special situation for the primitive array
} | java | private boolean canBeSkipped (TypeRef importedClass) {
// skip known imported classes and the ones in JRE
if (allReferencedTypes.contains(importedClass) || importedReferencedTypes.contains(importedClass) || importedClass.isJava())
return true;
// Skip the imported classes which are excluded
String classPackage = importedClass.getPackageRef().getFQN();
for (String excludePrefix: excludePrefixes) { // skip by the package prefix
if (classPackage.startsWith(excludePrefix))
return true;
}
if (excludes.contains(classPackage)) // skip by the full package name
return true;
return classPackage.length()<2; // special situation for the primitive array
} | [
"private",
"boolean",
"canBeSkipped",
"(",
"TypeRef",
"importedClass",
")",
"{",
"// skip known imported classes and the ones in JRE",
"if",
"(",
"allReferencedTypes",
".",
"contains",
"(",
"importedClass",
")",
"||",
"importedReferencedTypes",
".",
"contains",
"(",
"importedClass",
")",
"||",
"importedClass",
".",
"isJava",
"(",
")",
")",
"return",
"true",
";",
"// Skip the imported classes which are excluded ",
"String",
"classPackage",
"=",
"importedClass",
".",
"getPackageRef",
"(",
")",
".",
"getFQN",
"(",
")",
";",
"for",
"(",
"String",
"excludePrefix",
":",
"excludePrefixes",
")",
"{",
"// skip by the package prefix",
"if",
"(",
"classPackage",
".",
"startsWith",
"(",
"excludePrefix",
")",
")",
"return",
"true",
";",
"}",
"if",
"(",
"excludes",
".",
"contains",
"(",
"classPackage",
")",
")",
"// skip by the full package name",
"return",
"true",
";",
"return",
"classPackage",
".",
"length",
"(",
")",
"<",
"2",
";",
"// special situation for the primitive array ",
"}"
] | check whether a imported class should be considered in further dependency check
@param importedClass
@return | [
"check",
"whether",
"a",
"imported",
"class",
"should",
"be",
"considered",
"in",
"further",
"dependency",
"check"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/wlp-bndPlugins/src/com/ibm/ws/build/bnd/plugins/ImportlessPackager.java#L262-L275 | train |
OpenLiberty/open-liberty | dev/wlp-bndPlugins/src/com/ibm/ws/build/bnd/plugins/ImportlessPackager.java | ImportlessPackager.collectPackageDependencies | private Set<PackageRef> collectPackageDependencies() {
Set<PackageRef> referencedPackages = new HashSet<PackageRef> ();
for (TypeRef newReferencedType:importedReferencedTypes) {
PackageRef packageRef = newReferencedType.getPackageRef();
if (referencedPackages.contains(packageRef)) // package already known
continue;
referencedPackages.add(packageRef);
System.out.println("Add package: " + packageRef.getFQN());
}
return referencedPackages;
} | java | private Set<PackageRef> collectPackageDependencies() {
Set<PackageRef> referencedPackages = new HashSet<PackageRef> ();
for (TypeRef newReferencedType:importedReferencedTypes) {
PackageRef packageRef = newReferencedType.getPackageRef();
if (referencedPackages.contains(packageRef)) // package already known
continue;
referencedPackages.add(packageRef);
System.out.println("Add package: " + packageRef.getFQN());
}
return referencedPackages;
} | [
"private",
"Set",
"<",
"PackageRef",
">",
"collectPackageDependencies",
"(",
")",
"{",
"Set",
"<",
"PackageRef",
">",
"referencedPackages",
"=",
"new",
"HashSet",
"<",
"PackageRef",
">",
"(",
")",
";",
"for",
"(",
"TypeRef",
"newReferencedType",
":",
"importedReferencedTypes",
")",
"{",
"PackageRef",
"packageRef",
"=",
"newReferencedType",
".",
"getPackageRef",
"(",
")",
";",
"if",
"(",
"referencedPackages",
".",
"contains",
"(",
"packageRef",
")",
")",
"// package already known",
"continue",
";",
"referencedPackages",
".",
"add",
"(",
"packageRef",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Add package: \"",
"+",
"packageRef",
".",
"getFQN",
"(",
")",
")",
";",
"}",
"return",
"referencedPackages",
";",
"}"
] | Collect the referenced packages information from the referenced classes information
@return referencedPackages | [
"Collect",
"the",
"referenced",
"packages",
"information",
"from",
"the",
"referenced",
"classes",
"information"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/wlp-bndPlugins/src/com/ibm/ws/build/bnd/plugins/ImportlessPackager.java#L297-L307 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jca.utils/src/com/ibm/ws/jca/utils/xml/metatype/MetatypeOcd.java | MetatypeOcd.addMetatypeAd | public boolean addMetatypeAd(MetatypeAd metatypeAd) {
if (this.metatypeAds == null)
this.metatypeAds = new LinkedList<MetatypeAd>();
for (MetatypeAd ad : metatypeAds)
if (ad.getID().equals(metatypeAd.getID()))
return false;
this.metatypeAds.add(metatypeAd);
return true;
} | java | public boolean addMetatypeAd(MetatypeAd metatypeAd) {
if (this.metatypeAds == null)
this.metatypeAds = new LinkedList<MetatypeAd>();
for (MetatypeAd ad : metatypeAds)
if (ad.getID().equals(metatypeAd.getID()))
return false;
this.metatypeAds.add(metatypeAd);
return true;
} | [
"public",
"boolean",
"addMetatypeAd",
"(",
"MetatypeAd",
"metatypeAd",
")",
"{",
"if",
"(",
"this",
".",
"metatypeAds",
"==",
"null",
")",
"this",
".",
"metatypeAds",
"=",
"new",
"LinkedList",
"<",
"MetatypeAd",
">",
"(",
")",
";",
"for",
"(",
"MetatypeAd",
"ad",
":",
"metatypeAds",
")",
"if",
"(",
"ad",
".",
"getID",
"(",
")",
".",
"equals",
"(",
"metatypeAd",
".",
"getID",
"(",
")",
")",
")",
"return",
"false",
";",
"this",
".",
"metatypeAds",
".",
"add",
"(",
"metatypeAd",
")",
";",
"return",
"true",
";",
"}"
] | Adds a metatype AD.
@param metatypeAd the MetatypeAd to add
@return true if the MetatypeAd was added, else false if it already
exists in the list | [
"Adds",
"a",
"metatype",
"AD",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jca.utils/src/com/ibm/ws/jca/utils/xml/metatype/MetatypeOcd.java#L171-L181 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.channelfw/src/com/ibm/io/async/AsyncSocketChannel.java | AsyncSocketChannel.prepareSocket | public synchronized void prepareSocket() throws IOException {
if (!prepared) {
final long fd = getFileDescriptor();
if (fd == INVALID_SOCKET) {
throw new AsyncException(AsyncProperties.aio_handle_unavailable);
}
channelIdentifier = provider.prepare2(fd, asyncChannelGroup.getCompletionPort());
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "prepareSocket - socket prepared, fd = " + fd
+ " channel id: " + channelIdentifier + " "
+ ", local: " + channel.socket().getLocalSocketAddress()
+ ", remote: " + channel.socket().getRemoteSocketAddress());
}
long callid = 0; // init to zero, reset when IO requested
readIOCB = (CompletionKey) AsyncLibrary.completionKeyPool.get();
if (readIOCB != null) {
// initialize the IOCB from the pool
readIOCB.initializePoolEntry(channelIdentifier, callid);
writeIOCB = (CompletionKey) AsyncLibrary.completionKeyPool.get();
if (writeIOCB != null) {
// initialize the IOCB from the pool
writeIOCB.initializePoolEntry(channelIdentifier, callid);
} else {
writeIOCB = new CompletionKey(channelIdentifier, callid, defaultBufferCount);
}
} else {
readIOCB = new CompletionKey(channelIdentifier, callid, defaultBufferCount);
writeIOCB = new CompletionKey(channelIdentifier, callid, defaultBufferCount);
}
provider.initializeIOCB(readIOCB);
provider.initializeIOCB(writeIOCB);
prepared = true;
}
} | java | public synchronized void prepareSocket() throws IOException {
if (!prepared) {
final long fd = getFileDescriptor();
if (fd == INVALID_SOCKET) {
throw new AsyncException(AsyncProperties.aio_handle_unavailable);
}
channelIdentifier = provider.prepare2(fd, asyncChannelGroup.getCompletionPort());
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "prepareSocket - socket prepared, fd = " + fd
+ " channel id: " + channelIdentifier + " "
+ ", local: " + channel.socket().getLocalSocketAddress()
+ ", remote: " + channel.socket().getRemoteSocketAddress());
}
long callid = 0; // init to zero, reset when IO requested
readIOCB = (CompletionKey) AsyncLibrary.completionKeyPool.get();
if (readIOCB != null) {
// initialize the IOCB from the pool
readIOCB.initializePoolEntry(channelIdentifier, callid);
writeIOCB = (CompletionKey) AsyncLibrary.completionKeyPool.get();
if (writeIOCB != null) {
// initialize the IOCB from the pool
writeIOCB.initializePoolEntry(channelIdentifier, callid);
} else {
writeIOCB = new CompletionKey(channelIdentifier, callid, defaultBufferCount);
}
} else {
readIOCB = new CompletionKey(channelIdentifier, callid, defaultBufferCount);
writeIOCB = new CompletionKey(channelIdentifier, callid, defaultBufferCount);
}
provider.initializeIOCB(readIOCB);
provider.initializeIOCB(writeIOCB);
prepared = true;
}
} | [
"public",
"synchronized",
"void",
"prepareSocket",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"prepared",
")",
"{",
"final",
"long",
"fd",
"=",
"getFileDescriptor",
"(",
")",
";",
"if",
"(",
"fd",
"==",
"INVALID_SOCKET",
")",
"{",
"throw",
"new",
"AsyncException",
"(",
"AsyncProperties",
".",
"aio_handle_unavailable",
")",
";",
"}",
"channelIdentifier",
"=",
"provider",
".",
"prepare2",
"(",
"fd",
",",
"asyncChannelGroup",
".",
"getCompletionPort",
"(",
")",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"prepareSocket - socket prepared, fd = \"",
"+",
"fd",
"+",
"\" channel id: \"",
"+",
"channelIdentifier",
"+",
"\" \"",
"+",
"\", local: \"",
"+",
"channel",
".",
"socket",
"(",
")",
".",
"getLocalSocketAddress",
"(",
")",
"+",
"\", remote: \"",
"+",
"channel",
".",
"socket",
"(",
")",
".",
"getRemoteSocketAddress",
"(",
")",
")",
";",
"}",
"long",
"callid",
"=",
"0",
";",
"// init to zero, reset when IO requested",
"readIOCB",
"=",
"(",
"CompletionKey",
")",
"AsyncLibrary",
".",
"completionKeyPool",
".",
"get",
"(",
")",
";",
"if",
"(",
"readIOCB",
"!=",
"null",
")",
"{",
"// initialize the IOCB from the pool",
"readIOCB",
".",
"initializePoolEntry",
"(",
"channelIdentifier",
",",
"callid",
")",
";",
"writeIOCB",
"=",
"(",
"CompletionKey",
")",
"AsyncLibrary",
".",
"completionKeyPool",
".",
"get",
"(",
")",
";",
"if",
"(",
"writeIOCB",
"!=",
"null",
")",
"{",
"// initialize the IOCB from the pool",
"writeIOCB",
".",
"initializePoolEntry",
"(",
"channelIdentifier",
",",
"callid",
")",
";",
"}",
"else",
"{",
"writeIOCB",
"=",
"new",
"CompletionKey",
"(",
"channelIdentifier",
",",
"callid",
",",
"defaultBufferCount",
")",
";",
"}",
"}",
"else",
"{",
"readIOCB",
"=",
"new",
"CompletionKey",
"(",
"channelIdentifier",
",",
"callid",
",",
"defaultBufferCount",
")",
";",
"writeIOCB",
"=",
"new",
"CompletionKey",
"(",
"channelIdentifier",
",",
"callid",
",",
"defaultBufferCount",
")",
";",
"}",
"provider",
".",
"initializeIOCB",
"(",
"readIOCB",
")",
";",
"provider",
".",
"initializeIOCB",
"(",
"writeIOCB",
")",
";",
"prepared",
"=",
"true",
";",
"}",
"}"
] | Perform initialization steps for this new connection.
@throws IOException | [
"Perform",
"initialization",
"steps",
"for",
"this",
"new",
"connection",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/io/async/AsyncSocketChannel.java#L349-L387 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jsp/src/com/ibm/ws/jsp/taglib/TagFileClassInfo.java | TagFileClassInfo.getParameterClassName | public String getParameterClassName(String attributeName, JspCoreContext context) throws JspCoreException {
String parameterClassName = null;
if (parameterClassNameMap == null) {
parameterClassNameMap = new HashMap();
}
parameterClassName = (String)parameterClassNameMap.get(attributeName);
if (parameterClassName == null) {
TagAttributeInfo[] attributeInfos = ti.getAttributes();
for (int i = 0; i < attributeInfos.length; i++) {
if (attributeInfos[i].getName().equals(attributeName)) {
//PK69319
if(attributeInfos[i].isFragment()){
parameterClassName = "javax.servlet.jsp.tagext.JspFragment";
} else{
parameterClassName = attributeInfos[i].getTypeName();
}
parameterClassNameMap.put(attributeName, parameterClassName);
break;
}
}
}
return (parameterClassName);
} | java | public String getParameterClassName(String attributeName, JspCoreContext context) throws JspCoreException {
String parameterClassName = null;
if (parameterClassNameMap == null) {
parameterClassNameMap = new HashMap();
}
parameterClassName = (String)parameterClassNameMap.get(attributeName);
if (parameterClassName == null) {
TagAttributeInfo[] attributeInfos = ti.getAttributes();
for (int i = 0; i < attributeInfos.length; i++) {
if (attributeInfos[i].getName().equals(attributeName)) {
//PK69319
if(attributeInfos[i].isFragment()){
parameterClassName = "javax.servlet.jsp.tagext.JspFragment";
} else{
parameterClassName = attributeInfos[i].getTypeName();
}
parameterClassNameMap.put(attributeName, parameterClassName);
break;
}
}
}
return (parameterClassName);
} | [
"public",
"String",
"getParameterClassName",
"(",
"String",
"attributeName",
",",
"JspCoreContext",
"context",
")",
"throws",
"JspCoreException",
"{",
"String",
"parameterClassName",
"=",
"null",
";",
"if",
"(",
"parameterClassNameMap",
"==",
"null",
")",
"{",
"parameterClassNameMap",
"=",
"new",
"HashMap",
"(",
")",
";",
"}",
"parameterClassName",
"=",
"(",
"String",
")",
"parameterClassNameMap",
".",
"get",
"(",
"attributeName",
")",
";",
"if",
"(",
"parameterClassName",
"==",
"null",
")",
"{",
"TagAttributeInfo",
"[",
"]",
"attributeInfos",
"=",
"ti",
".",
"getAttributes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"attributeInfos",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"attributeInfos",
"[",
"i",
"]",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"attributeName",
")",
")",
"{",
"//PK69319",
"if",
"(",
"attributeInfos",
"[",
"i",
"]",
".",
"isFragment",
"(",
")",
")",
"{",
"parameterClassName",
"=",
"\"javax.servlet.jsp.tagext.JspFragment\"",
";",
"}",
"else",
"{",
"parameterClassName",
"=",
"attributeInfos",
"[",
"i",
"]",
".",
"getTypeName",
"(",
")",
";",
"}",
"parameterClassNameMap",
".",
"put",
"(",
"attributeName",
",",
"parameterClassName",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"(",
"parameterClassName",
")",
";",
"}"
] | PK36246 && 417178 override method in TagClassInfo, but since we aren't loading a class right now, we don't have to worry about the classpath in the context | [
"PK36246",
"&&",
"417178",
"override",
"method",
"in",
"TagClassInfo",
"but",
"since",
"we",
"aren",
"t",
"loading",
"a",
"class",
"right",
"now",
"we",
"don",
"t",
"have",
"to",
"worry",
"about",
"the",
"classpath",
"in",
"the",
"context"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsp/src/com/ibm/ws/jsp/taglib/TagFileClassInfo.java#L62-L87 | train |
OpenLiberty/open-liberty | dev/wlp.lib.extract/src/wlp/lib/extract/ChangeHistory.java | ChangeHistory.rollback | public ReturnCode rollback() {
while (!history.isEmpty()) {
final Action action = (Action) history.pop();
final ReturnCode ret = action.execute();
if (ret.getCode() != 0) {
return ret;
}
}
return ReturnCode.OK;
} | java | public ReturnCode rollback() {
while (!history.isEmpty()) {
final Action action = (Action) history.pop();
final ReturnCode ret = action.execute();
if (ret.getCode() != 0) {
return ret;
}
}
return ReturnCode.OK;
} | [
"public",
"ReturnCode",
"rollback",
"(",
")",
"{",
"while",
"(",
"!",
"history",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"Action",
"action",
"=",
"(",
"Action",
")",
"history",
".",
"pop",
"(",
")",
";",
"final",
"ReturnCode",
"ret",
"=",
"action",
".",
"execute",
"(",
")",
";",
"if",
"(",
"ret",
".",
"getCode",
"(",
")",
"!=",
"0",
")",
"{",
"return",
"ret",
";",
"}",
"}",
"return",
"ReturnCode",
".",
"OK",
";",
"}"
] | Attempts to undo changes in reverse order of actions taken; | [
"Attempts",
"to",
"undo",
"changes",
"in",
"reverse",
"order",
"of",
"actions",
"taken",
";"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/wlp.lib.extract/src/wlp/lib/extract/ChangeHistory.java#L102-L111 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLDiscriminatorState.java | SSLDiscriminatorState.updateState | public void updateState(SSLContext context, SSLEngine engine, SSLEngineResult result, WsByteBuffer decNetBuf, int position, int limit) {
this.sslContext = context;
this.sslEngine = engine;
this.sslEngineResult = result;
this.decryptedNetBuffer = decNetBuf;
this.netBufferPosition = position;
this.netBufferLimit = limit;
} | java | public void updateState(SSLContext context, SSLEngine engine, SSLEngineResult result, WsByteBuffer decNetBuf, int position, int limit) {
this.sslContext = context;
this.sslEngine = engine;
this.sslEngineResult = result;
this.decryptedNetBuffer = decNetBuf;
this.netBufferPosition = position;
this.netBufferLimit = limit;
} | [
"public",
"void",
"updateState",
"(",
"SSLContext",
"context",
",",
"SSLEngine",
"engine",
",",
"SSLEngineResult",
"result",
",",
"WsByteBuffer",
"decNetBuf",
",",
"int",
"position",
",",
"int",
"limit",
")",
"{",
"this",
".",
"sslContext",
"=",
"context",
";",
"this",
".",
"sslEngine",
"=",
"engine",
";",
"this",
".",
"sslEngineResult",
"=",
"result",
";",
"this",
".",
"decryptedNetBuffer",
"=",
"decNetBuf",
";",
"this",
".",
"netBufferPosition",
"=",
"position",
";",
"this",
".",
"netBufferLimit",
"=",
"limit",
";",
"}"
] | Update this state object with current information. This is called when a
YES response comes from the discriminator. The position and limit must be
saved here so the ready method can adjust them right away.
@param context
@param engine
@param result
@param decNetBuf
@param position
@param limit | [
"Update",
"this",
"state",
"object",
"with",
"current",
"information",
".",
"This",
"is",
"called",
"when",
"a",
"YES",
"response",
"comes",
"from",
"the",
"discriminator",
".",
"The",
"position",
"and",
"limit",
"must",
"be",
"saved",
"here",
"so",
"the",
"ready",
"method",
"can",
"adjust",
"them",
"right",
"away",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLDiscriminatorState.java#L59-L66 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/ejb/injection/processor/EJBInjectionBinding.java | EJBInjectionBinding.setXMLBeanInterface | private void setXMLBeanInterface(String homeInterfaceName, String interfaceName) // F743-32443
throws InjectionException
{
// If a home or business interface was specified in XML, then set that as
// the injection type. Both may be null if the XML just provides an
// override of an annotation to add <ejb-link>... in which case the
// injection class type will be set when the annotation is processed.
// For performance, there is no need to load these classes until first
// accessed, which might be never if there is a binding file, so just the
// name will be set here. getInjectionClassType() is then overridden to load
// the class when needed. Prior to EJB 3.0 these interfaces were completely
// ignored, so this behavior allows EJB 2.1 apps to continue to function
// even if they had garbage in their deployment descriptor. d739281
if (homeInterfaceName != null && homeInterfaceName.length() != 0) // d668376
{
ivHomeInterface = true;
setInjectionClassTypeName(homeInterfaceName);
if (isValidationLoggable())
{
loadClass(homeInterfaceName, isValidationFailable());
loadClass(interfaceName, isValidationFailable());
}
}
else if (interfaceName != null && interfaceName.length() != 0) // d668376
{
ivBeanInterface = true;
setInjectionClassTypeName(interfaceName);
if (isValidationLoggable())
{
loadClass(interfaceName, isValidationFailable());
}
}
} | java | private void setXMLBeanInterface(String homeInterfaceName, String interfaceName) // F743-32443
throws InjectionException
{
// If a home or business interface was specified in XML, then set that as
// the injection type. Both may be null if the XML just provides an
// override of an annotation to add <ejb-link>... in which case the
// injection class type will be set when the annotation is processed.
// For performance, there is no need to load these classes until first
// accessed, which might be never if there is a binding file, so just the
// name will be set here. getInjectionClassType() is then overridden to load
// the class when needed. Prior to EJB 3.0 these interfaces were completely
// ignored, so this behavior allows EJB 2.1 apps to continue to function
// even if they had garbage in their deployment descriptor. d739281
if (homeInterfaceName != null && homeInterfaceName.length() != 0) // d668376
{
ivHomeInterface = true;
setInjectionClassTypeName(homeInterfaceName);
if (isValidationLoggable())
{
loadClass(homeInterfaceName, isValidationFailable());
loadClass(interfaceName, isValidationFailable());
}
}
else if (interfaceName != null && interfaceName.length() != 0) // d668376
{
ivBeanInterface = true;
setInjectionClassTypeName(interfaceName);
if (isValidationLoggable())
{
loadClass(interfaceName, isValidationFailable());
}
}
} | [
"private",
"void",
"setXMLBeanInterface",
"(",
"String",
"homeInterfaceName",
",",
"String",
"interfaceName",
")",
"// F743-32443",
"throws",
"InjectionException",
"{",
"// If a home or business interface was specified in XML, then set that as",
"// the injection type. Both may be null if the XML just provides an",
"// override of an annotation to add <ejb-link>... in which case the",
"// injection class type will be set when the annotation is processed.",
"// For performance, there is no need to load these classes until first",
"// accessed, which might be never if there is a binding file, so just the",
"// name will be set here. getInjectionClassType() is then overridden to load",
"// the class when needed. Prior to EJB 3.0 these interfaces were completely",
"// ignored, so this behavior allows EJB 2.1 apps to continue to function",
"// even if they had garbage in their deployment descriptor. d739281",
"if",
"(",
"homeInterfaceName",
"!=",
"null",
"&&",
"homeInterfaceName",
".",
"length",
"(",
")",
"!=",
"0",
")",
"// d668376",
"{",
"ivHomeInterface",
"=",
"true",
";",
"setInjectionClassTypeName",
"(",
"homeInterfaceName",
")",
";",
"if",
"(",
"isValidationLoggable",
"(",
")",
")",
"{",
"loadClass",
"(",
"homeInterfaceName",
",",
"isValidationFailable",
"(",
")",
")",
";",
"loadClass",
"(",
"interfaceName",
",",
"isValidationFailable",
"(",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"interfaceName",
"!=",
"null",
"&&",
"interfaceName",
".",
"length",
"(",
")",
"!=",
"0",
")",
"// d668376",
"{",
"ivBeanInterface",
"=",
"true",
";",
"setInjectionClassTypeName",
"(",
"interfaceName",
")",
";",
"if",
"(",
"isValidationLoggable",
"(",
")",
")",
"{",
"loadClass",
"(",
"interfaceName",
",",
"isValidationFailable",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Sets the beanInterface as specified by XML. | [
"Sets",
"the",
"beanInterface",
"as",
"specified",
"by",
"XML",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/ejb/injection/processor/EJBInjectionBinding.java#L265-L300 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/ejb/injection/processor/EJBInjectionBinding.java | EJBInjectionBinding.setBindingName | private void setBindingName() // d681743
throws InjectionException
{
Map<String, String> ejbRefBindings = ivNameSpaceConfig.getEJBRefBindings();
if (ejbRefBindings != null)
{
ivBindingName = ejbRefBindings.get(getJndiName());
if (ivBindingName != null && ivBindingName.equals(""))
{
ivBindingName = null;
Tr.warning(tc, "EJB_BOUND_TO_EMPTY_STRING_CWNEN0025W");
if (isValidationFailable()) // fail if enabled F743-14449
{
InjectionConfigurationException icex = new InjectionConfigurationException
("The " + getJndiName() + " EJB reference in the " + ivModule +
" module of the " + ivApplication + " application has been" +
" bound to the empty string in the global Java Naming and Directory Interface (JNDI) namespace.");
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "resolve : " + icex);
throw icex;
}
}
}
} | java | private void setBindingName() // d681743
throws InjectionException
{
Map<String, String> ejbRefBindings = ivNameSpaceConfig.getEJBRefBindings();
if (ejbRefBindings != null)
{
ivBindingName = ejbRefBindings.get(getJndiName());
if (ivBindingName != null && ivBindingName.equals(""))
{
ivBindingName = null;
Tr.warning(tc, "EJB_BOUND_TO_EMPTY_STRING_CWNEN0025W");
if (isValidationFailable()) // fail if enabled F743-14449
{
InjectionConfigurationException icex = new InjectionConfigurationException
("The " + getJndiName() + " EJB reference in the " + ivModule +
" module of the " + ivApplication + " application has been" +
" bound to the empty string in the global Java Naming and Directory Interface (JNDI) namespace.");
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "resolve : " + icex);
throw icex;
}
}
}
} | [
"private",
"void",
"setBindingName",
"(",
")",
"// d681743",
"throws",
"InjectionException",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"ejbRefBindings",
"=",
"ivNameSpaceConfig",
".",
"getEJBRefBindings",
"(",
")",
";",
"if",
"(",
"ejbRefBindings",
"!=",
"null",
")",
"{",
"ivBindingName",
"=",
"ejbRefBindings",
".",
"get",
"(",
"getJndiName",
"(",
")",
")",
";",
"if",
"(",
"ivBindingName",
"!=",
"null",
"&&",
"ivBindingName",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"ivBindingName",
"=",
"null",
";",
"Tr",
".",
"warning",
"(",
"tc",
",",
"\"EJB_BOUND_TO_EMPTY_STRING_CWNEN0025W\"",
")",
";",
"if",
"(",
"isValidationFailable",
"(",
")",
")",
"// fail if enabled F743-14449",
"{",
"InjectionConfigurationException",
"icex",
"=",
"new",
"InjectionConfigurationException",
"(",
"\"The \"",
"+",
"getJndiName",
"(",
")",
"+",
"\" EJB reference in the \"",
"+",
"ivModule",
"+",
"\" module of the \"",
"+",
"ivApplication",
"+",
"\" application has been\"",
"+",
"\" bound to the empty string in the global Java Naming and Directory Interface (JNDI) namespace.\"",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"tc",
",",
"\"resolve : \"",
"+",
"icex",
")",
";",
"throw",
"icex",
";",
"}",
"}",
"}",
"}"
] | Returns true if the user has configured a binding for this reference. | [
"Returns",
"true",
"if",
"the",
"user",
"has",
"configured",
"a",
"binding",
"for",
"this",
"reference",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/ejb/injection/processor/EJBInjectionBinding.java#L305-L329 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/ejb/injection/processor/EJBInjectionBinding.java | EJBInjectionBinding.addInjectionTarget | @Override
public void addInjectionTarget(Member member)
throws InjectionException
{
// If the beanName attribute was found in the constructor or merge
// method, then save the class of where it was located.
if (ivBeanName != null && ivBeanNameClass == null) {
ivBeanNameClass = member.getDeclaringClass();
}
super.addInjectionTarget(member);
} | java | @Override
public void addInjectionTarget(Member member)
throws InjectionException
{
// If the beanName attribute was found in the constructor or merge
// method, then save the class of where it was located.
if (ivBeanName != null && ivBeanNameClass == null) {
ivBeanNameClass = member.getDeclaringClass();
}
super.addInjectionTarget(member);
} | [
"@",
"Override",
"public",
"void",
"addInjectionTarget",
"(",
"Member",
"member",
")",
"throws",
"InjectionException",
"{",
"// If the beanName attribute was found in the constructor or merge",
"// method, then save the class of where it was located.",
"if",
"(",
"ivBeanName",
"!=",
"null",
"&&",
"ivBeanNameClass",
"==",
"null",
")",
"{",
"ivBeanNameClass",
"=",
"member",
".",
"getDeclaringClass",
"(",
")",
";",
"}",
"super",
".",
"addInjectionTarget",
"(",
"member",
")",
";",
"}"
] | d638111.1 | [
"d638111",
".",
"1"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/ejb/injection/processor/EJBInjectionBinding.java#L343-L354 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.monitor/src/com/ibm/ws/monitor/internal/bci/ProbeAtThrowMethodAdapter.java | ProbeAtThrowMethodAdapter.visitInsn | @Override
public void visitInsn(int opcode) {
if (opcode == ATHROW && !enabledListeners.isEmpty()) {
String key = createKey();
ProbeImpl probe = getProbe(key);
long probeId = probe.getIdentifier();
setProbeInProgress(true);
visitInsn(DUP); // throwable throwable
visitLdcInsn(Long.valueOf(probeId)); // throwable throwable long1 long2
visitInsn(DUP2_X1); // throwable long1 long2 throwable long1 long2
visitInsn(POP2); // throwable long1 long2 throwable
if (isStatic()) {
visitInsn(ACONST_NULL); // throwable long1 long2 throwable this
} else {
visitVarInsn(ALOAD, 0); // throwable long1 long2 throwable this
}
visitInsn(SWAP); // throwable long1 long2 this throwable
visitInsn(ACONST_NULL); // throwable long1 long2 this throwable null
visitInsn(SWAP); // throwable long1 long2 this null throwable
visitFireProbeInvocation(); // throwable
setProbeInProgress(false);
setProbeListeners(probe, enabledListeners);
}
super.visitInsn(opcode);
} | java | @Override
public void visitInsn(int opcode) {
if (opcode == ATHROW && !enabledListeners.isEmpty()) {
String key = createKey();
ProbeImpl probe = getProbe(key);
long probeId = probe.getIdentifier();
setProbeInProgress(true);
visitInsn(DUP); // throwable throwable
visitLdcInsn(Long.valueOf(probeId)); // throwable throwable long1 long2
visitInsn(DUP2_X1); // throwable long1 long2 throwable long1 long2
visitInsn(POP2); // throwable long1 long2 throwable
if (isStatic()) {
visitInsn(ACONST_NULL); // throwable long1 long2 throwable this
} else {
visitVarInsn(ALOAD, 0); // throwable long1 long2 throwable this
}
visitInsn(SWAP); // throwable long1 long2 this throwable
visitInsn(ACONST_NULL); // throwable long1 long2 this throwable null
visitInsn(SWAP); // throwable long1 long2 this null throwable
visitFireProbeInvocation(); // throwable
setProbeInProgress(false);
setProbeListeners(probe, enabledListeners);
}
super.visitInsn(opcode);
} | [
"@",
"Override",
"public",
"void",
"visitInsn",
"(",
"int",
"opcode",
")",
"{",
"if",
"(",
"opcode",
"==",
"ATHROW",
"&&",
"!",
"enabledListeners",
".",
"isEmpty",
"(",
")",
")",
"{",
"String",
"key",
"=",
"createKey",
"(",
")",
";",
"ProbeImpl",
"probe",
"=",
"getProbe",
"(",
"key",
")",
";",
"long",
"probeId",
"=",
"probe",
".",
"getIdentifier",
"(",
")",
";",
"setProbeInProgress",
"(",
"true",
")",
";",
"visitInsn",
"(",
"DUP",
")",
";",
"// throwable throwable",
"visitLdcInsn",
"(",
"Long",
".",
"valueOf",
"(",
"probeId",
")",
")",
";",
"// throwable throwable long1 long2",
"visitInsn",
"(",
"DUP2_X1",
")",
";",
"// throwable long1 long2 throwable long1 long2",
"visitInsn",
"(",
"POP2",
")",
";",
"// throwable long1 long2 throwable",
"if",
"(",
"isStatic",
"(",
")",
")",
"{",
"visitInsn",
"(",
"ACONST_NULL",
")",
";",
"// throwable long1 long2 throwable this",
"}",
"else",
"{",
"visitVarInsn",
"(",
"ALOAD",
",",
"0",
")",
";",
"// throwable long1 long2 throwable this",
"}",
"visitInsn",
"(",
"SWAP",
")",
";",
"// throwable long1 long2 this throwable",
"visitInsn",
"(",
"ACONST_NULL",
")",
";",
"// throwable long1 long2 this throwable null",
"visitInsn",
"(",
"SWAP",
")",
";",
"// throwable long1 long2 this null throwable",
"visitFireProbeInvocation",
"(",
")",
";",
"// throwable",
"setProbeInProgress",
"(",
"false",
")",
";",
"setProbeListeners",
"(",
"probe",
",",
"enabledListeners",
")",
";",
"}",
"super",
".",
"visitInsn",
"(",
"opcode",
")",
";",
"}"
] | Inject code to fire a probe before any throw instruction. | [
"Inject",
"code",
"to",
"fire",
"a",
"probe",
"before",
"any",
"throw",
"instruction",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.monitor/src/com/ibm/ws/monitor/internal/bci/ProbeAtThrowMethodAdapter.java#L63-L90 | train |
OpenLiberty/open-liberty | dev/com.ibm.rls.jdbc/src/com/ibm/ws/recoverylog/custom/jdbc/impl/SQLRecoverableUnitSectionImpl.java | SQLRecoverableUnitSectionImpl.addData | public void addData(int index, byte[] data) throws InternalLogException
{
if (tc.isEntryEnabled()) Tr.entry(tc, "addData",new java.lang.Object[] {new Integer(index), RLSUtils.toHexString(data,RLSUtils.MAX_DISPLAY_BYTES), this});
// If the parent recovery log instance has experienced a serious internal error then prevent
// this operation from executing.
if (_recLog.failed())
{
if (tc.isEntryEnabled()) Tr.exit(tc, "addData",this);
throw new InternalLogException(null);
}
// we use an index value of 0 to indicate that it is a singledata RUsection
// so adjust now ... if (!_singleData) or if(index != 0)
if (index > 0) index--;
// list items may be added in any order, so it may be necessary to (temporarily) pad the list
final int currentSize = _writtenData.size();
if (index == currentSize)
_writtenData.add(/*index,*/ data);
else if (index < currentSize)
{
if (tc.isDebugEnabled()) Tr.debug(tc, "NMTEST: Replacing item (expect trace 'null') at index: " + index, _writtenData.get(index));
_writtenData.set(index, data);
}
else // index > currentSize
{
if (tc.isDebugEnabled()) Tr.debug(tc, "NMTEST: Adding null elements: " + (index-currentSize));
while (index-- > currentSize)
_writtenData.add(null);
_writtenData.add(data);
}
// set lastdata. This method is called during recovery and we shouldn't get asked for
// any data until all log records are read. So set lastdata to be the item at the current size
// of the array. Items may be added in random order, so lastitem will be correct when
// all items have been added
_lastDataItem = (byte[]) _writtenData.get(_writtenData.size() -1);
if (tc.isEntryEnabled()) Tr.exit(tc, "addData");
} | java | public void addData(int index, byte[] data) throws InternalLogException
{
if (tc.isEntryEnabled()) Tr.entry(tc, "addData",new java.lang.Object[] {new Integer(index), RLSUtils.toHexString(data,RLSUtils.MAX_DISPLAY_BYTES), this});
// If the parent recovery log instance has experienced a serious internal error then prevent
// this operation from executing.
if (_recLog.failed())
{
if (tc.isEntryEnabled()) Tr.exit(tc, "addData",this);
throw new InternalLogException(null);
}
// we use an index value of 0 to indicate that it is a singledata RUsection
// so adjust now ... if (!_singleData) or if(index != 0)
if (index > 0) index--;
// list items may be added in any order, so it may be necessary to (temporarily) pad the list
final int currentSize = _writtenData.size();
if (index == currentSize)
_writtenData.add(/*index,*/ data);
else if (index < currentSize)
{
if (tc.isDebugEnabled()) Tr.debug(tc, "NMTEST: Replacing item (expect trace 'null') at index: " + index, _writtenData.get(index));
_writtenData.set(index, data);
}
else // index > currentSize
{
if (tc.isDebugEnabled()) Tr.debug(tc, "NMTEST: Adding null elements: " + (index-currentSize));
while (index-- > currentSize)
_writtenData.add(null);
_writtenData.add(data);
}
// set lastdata. This method is called during recovery and we shouldn't get asked for
// any data until all log records are read. So set lastdata to be the item at the current size
// of the array. Items may be added in random order, so lastitem will be correct when
// all items have been added
_lastDataItem = (byte[]) _writtenData.get(_writtenData.size() -1);
if (tc.isEntryEnabled()) Tr.exit(tc, "addData");
} | [
"public",
"void",
"addData",
"(",
"int",
"index",
",",
"byte",
"[",
"]",
"data",
")",
"throws",
"InternalLogException",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"entry",
"(",
"tc",
",",
"\"addData\"",
",",
"new",
"java",
".",
"lang",
".",
"Object",
"[",
"]",
"{",
"new",
"Integer",
"(",
"index",
")",
",",
"RLSUtils",
".",
"toHexString",
"(",
"data",
",",
"RLSUtils",
".",
"MAX_DISPLAY_BYTES",
")",
",",
"this",
"}",
")",
";",
"// If the parent recovery log instance has experienced a serious internal error then prevent",
"// this operation from executing.",
"if",
"(",
"_recLog",
".",
"failed",
"(",
")",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"tc",
",",
"\"addData\"",
",",
"this",
")",
";",
"throw",
"new",
"InternalLogException",
"(",
"null",
")",
";",
"}",
"// we use an index value of 0 to indicate that it is a singledata RUsection",
"// so adjust now ... if (!_singleData) or if(index != 0)",
"if",
"(",
"index",
">",
"0",
")",
"index",
"--",
";",
"// list items may be added in any order, so it may be necessary to (temporarily) pad the list",
"final",
"int",
"currentSize",
"=",
"_writtenData",
".",
"size",
"(",
")",
";",
"if",
"(",
"index",
"==",
"currentSize",
")",
"_writtenData",
".",
"add",
"(",
"/*index,*/",
"data",
")",
";",
"else",
"if",
"(",
"index",
"<",
"currentSize",
")",
"{",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"NMTEST: Replacing item (expect trace 'null') at index: \"",
"+",
"index",
",",
"_writtenData",
".",
"get",
"(",
"index",
")",
")",
";",
"_writtenData",
".",
"set",
"(",
"index",
",",
"data",
")",
";",
"}",
"else",
"// index > currentSize",
"{",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"NMTEST: Adding null elements: \"",
"+",
"(",
"index",
"-",
"currentSize",
")",
")",
";",
"while",
"(",
"index",
"--",
">",
"currentSize",
")",
"_writtenData",
".",
"add",
"(",
"null",
")",
";",
"_writtenData",
".",
"add",
"(",
"data",
")",
";",
"}",
"// set lastdata. This method is called during recovery and we shouldn't get asked for",
"// any data until all log records are read. So set lastdata to be the item at the current size",
"// of the array. Items may be added in random order, so lastitem will be correct when",
"// all items have been added",
"_lastDataItem",
"=",
"(",
"byte",
"[",
"]",
")",
"_writtenData",
".",
"get",
"(",
"_writtenData",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"tc",
",",
"\"addData\"",
")",
";",
"}"
] | recovery method to add data directly to _writtenData array | [
"recovery",
"method",
"to",
"add",
"data",
"directly",
"to",
"_writtenData",
"array"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.rls.jdbc/src/com/ibm/ws/recoverylog/custom/jdbc/impl/SQLRecoverableUnitSectionImpl.java#L327-L368 | train |
OpenLiberty/open-liberty | dev/com.ibm.rls.jdbc/src/com/ibm/ws/recoverylog/custom/jdbc/impl/SQLRecoverableUnitSectionImpl.java | SQLRecoverableUnitSectionImpl.identity | public int identity()
{
if (tc.isEntryEnabled()) Tr.entry(tc, "identity",this);
if (tc.isEntryEnabled()) Tr.exit(tc, "identity",new Integer(_identity));
return _identity;
} | java | public int identity()
{
if (tc.isEntryEnabled()) Tr.entry(tc, "identity",this);
if (tc.isEntryEnabled()) Tr.exit(tc, "identity",new Integer(_identity));
return _identity;
} | [
"public",
"int",
"identity",
"(",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"entry",
"(",
"tc",
",",
"\"identity\"",
",",
"this",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"tc",
",",
"\"identity\"",
",",
"new",
"Integer",
"(",
"_identity",
")",
")",
";",
"return",
"_identity",
";",
"}"
] | Returns the identity of the recoverable unit section.
@return The identity of the recoverable unit section. | [
"Returns",
"the",
"identity",
"of",
"the",
"recoverable",
"unit",
"section",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.rls.jdbc/src/com/ibm/ws/recoverylog/custom/jdbc/impl/SQLRecoverableUnitSectionImpl.java#L596-L601 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/h2internal/hpack/IntegerRepresentation.java | IntegerRepresentation.decode | public static int decode(WsByteBuffer headerBlock, int N) {
// if (!headerBlock.hasRemaining()) {
// throw new HeaderFieldDecodingException("No length to decode");
// }
int I = HpackUtils.getLSB(headerBlock.get(), N);
if (I < HpackUtils.ipow(2, N) - 1) {
return I;
} else {
int M = 0;
boolean done = false;
byte b;
while (done == false) {
// If there are no further elements, this is an invalid HeaderBlock.
// If this decode method is called, there should always be header
// key value bytes after the integer representation.
// if (!headerBlock.hasRemaining()) {
// throw new HeaderFieldDecodingException("");
// }
b = headerBlock.get();
I = I + ((b) & 127) * HpackUtils.ipow(2, M);
M = M + 7;
if (((b & 128) == 128) == false)
done = true;
}
return I;
}
} | java | public static int decode(WsByteBuffer headerBlock, int N) {
// if (!headerBlock.hasRemaining()) {
// throw new HeaderFieldDecodingException("No length to decode");
// }
int I = HpackUtils.getLSB(headerBlock.get(), N);
if (I < HpackUtils.ipow(2, N) - 1) {
return I;
} else {
int M = 0;
boolean done = false;
byte b;
while (done == false) {
// If there are no further elements, this is an invalid HeaderBlock.
// If this decode method is called, there should always be header
// key value bytes after the integer representation.
// if (!headerBlock.hasRemaining()) {
// throw new HeaderFieldDecodingException("");
// }
b = headerBlock.get();
I = I + ((b) & 127) * HpackUtils.ipow(2, M);
M = M + 7;
if (((b & 128) == 128) == false)
done = true;
}
return I;
}
} | [
"public",
"static",
"int",
"decode",
"(",
"WsByteBuffer",
"headerBlock",
",",
"int",
"N",
")",
"{",
"// if (!headerBlock.hasRemaining()) {",
"// throw new HeaderFieldDecodingException(\"No length to decode\");",
"// }",
"int",
"I",
"=",
"HpackUtils",
".",
"getLSB",
"(",
"headerBlock",
".",
"get",
"(",
")",
",",
"N",
")",
";",
"if",
"(",
"I",
"<",
"HpackUtils",
".",
"ipow",
"(",
"2",
",",
"N",
")",
"-",
"1",
")",
"{",
"return",
"I",
";",
"}",
"else",
"{",
"int",
"M",
"=",
"0",
";",
"boolean",
"done",
"=",
"false",
";",
"byte",
"b",
";",
"while",
"(",
"done",
"==",
"false",
")",
"{",
"// If there are no further elements, this is an invalid HeaderBlock.",
"// If this decode method is called, there should always be header",
"// key value bytes after the integer representation.",
"// if (!headerBlock.hasRemaining()) {",
"// throw new HeaderFieldDecodingException(\"\");",
"// }",
"b",
"=",
"headerBlock",
".",
"get",
"(",
")",
";",
"I",
"=",
"I",
"+",
"(",
"(",
"b",
")",
"&",
"127",
")",
"*",
"HpackUtils",
".",
"ipow",
"(",
"2",
",",
"M",
")",
";",
"M",
"=",
"M",
"+",
"7",
";",
"if",
"(",
"(",
"(",
"b",
"&",
"128",
")",
"==",
"128",
")",
"==",
"false",
")",
"done",
"=",
"true",
";",
"}",
"return",
"I",
";",
"}",
"}"
] | Decodes a provided byte array that was encoded using an N-bit
prefix.
@param ba
@param N
@return
@throws HeaderFieldDecodingException | [
"Decodes",
"a",
"provided",
"byte",
"array",
"that",
"was",
"encoded",
"using",
"an",
"N",
"-",
"bit",
"prefix",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/h2internal/hpack/IntegerRepresentation.java#L196-L229 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.csiv2.common/src/com/ibm/ws/transport/iiop/asn1/DERBitString.java | DERBitString.getPadBits | static protected int getPadBits(
int bitString)
{
int val = 0;
for (int i = 3; i >= 0; i--)
{
//
// this may look a little odd, but if it isn't done like this pre jdk1.2
// JVM's break!
//
if (i != 0)
{
if ((bitString >> (i * 8)) != 0)
{
val = (bitString >> (i * 8)) & 0xFF;
break;
}
}
else
{
if (bitString != 0)
{
val = bitString & 0xFF;
break;
}
}
}
if (val == 0)
{
return 7;
}
int bits = 1;
while (((val <<= 1) & 0xFF) != 0)
{
bits++;
}
return 8 - bits;
} | java | static protected int getPadBits(
int bitString)
{
int val = 0;
for (int i = 3; i >= 0; i--)
{
//
// this may look a little odd, but if it isn't done like this pre jdk1.2
// JVM's break!
//
if (i != 0)
{
if ((bitString >> (i * 8)) != 0)
{
val = (bitString >> (i * 8)) & 0xFF;
break;
}
}
else
{
if (bitString != 0)
{
val = bitString & 0xFF;
break;
}
}
}
if (val == 0)
{
return 7;
}
int bits = 1;
while (((val <<= 1) & 0xFF) != 0)
{
bits++;
}
return 8 - bits;
} | [
"static",
"protected",
"int",
"getPadBits",
"(",
"int",
"bitString",
")",
"{",
"int",
"val",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"3",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"//",
"// this may look a little odd, but if it isn't done like this pre jdk1.2",
"// JVM's break!",
"//",
"if",
"(",
"i",
"!=",
"0",
")",
"{",
"if",
"(",
"(",
"bitString",
">>",
"(",
"i",
"*",
"8",
")",
")",
"!=",
"0",
")",
"{",
"val",
"=",
"(",
"bitString",
">>",
"(",
"i",
"*",
"8",
")",
")",
"&",
"0xFF",
";",
"break",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"bitString",
"!=",
"0",
")",
"{",
"val",
"=",
"bitString",
"&",
"0xFF",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"val",
"==",
"0",
")",
"{",
"return",
"7",
";",
"}",
"int",
"bits",
"=",
"1",
";",
"while",
"(",
"(",
"(",
"val",
"<<=",
"1",
")",
"&",
"0xFF",
")",
"!=",
"0",
")",
"{",
"bits",
"++",
";",
"}",
"return",
"8",
"-",
"bits",
";",
"}"
] | return the correct number of pad bits for a bit string defined in
a 32 bit constant | [
"return",
"the",
"correct",
"number",
"of",
"pad",
"bits",
"for",
"a",
"bit",
"string",
"defined",
"in",
"a",
"32",
"bit",
"constant"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.csiv2.common/src/com/ibm/ws/transport/iiop/asn1/DERBitString.java#L33-L75 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.csiv2.common/src/com/ibm/ws/transport/iiop/asn1/DERBitString.java | DERBitString.getBytes | static protected byte[] getBytes(int bitString)
{
int bytes = 4;
for (int i = 3; i >= 1; i--)
{
if ((bitString & (0xFF << (i * 8))) != 0)
{
break;
}
bytes--;
}
byte[] result = new byte[bytes];
for (int i = 0; i < bytes; i++)
{
result[i] = (byte) ((bitString >> (i * 8)) & 0xFF);
}
return result;
} | java | static protected byte[] getBytes(int bitString)
{
int bytes = 4;
for (int i = 3; i >= 1; i--)
{
if ((bitString & (0xFF << (i * 8))) != 0)
{
break;
}
bytes--;
}
byte[] result = new byte[bytes];
for (int i = 0; i < bytes; i++)
{
result[i] = (byte) ((bitString >> (i * 8)) & 0xFF);
}
return result;
} | [
"static",
"protected",
"byte",
"[",
"]",
"getBytes",
"(",
"int",
"bitString",
")",
"{",
"int",
"bytes",
"=",
"4",
";",
"for",
"(",
"int",
"i",
"=",
"3",
";",
"i",
">=",
"1",
";",
"i",
"--",
")",
"{",
"if",
"(",
"(",
"bitString",
"&",
"(",
"0xFF",
"<<",
"(",
"i",
"*",
"8",
")",
")",
")",
"!=",
"0",
")",
"{",
"break",
";",
"}",
"bytes",
"--",
";",
"}",
"byte",
"[",
"]",
"result",
"=",
"new",
"byte",
"[",
"bytes",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"bytes",
";",
"i",
"++",
")",
"{",
"result",
"[",
"i",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"bitString",
">>",
"(",
"i",
"*",
"8",
")",
")",
"&",
"0xFF",
")",
";",
"}",
"return",
"result",
";",
"}"
] | return the correct number of bytes for a bit string defined in
a 32 bit constant | [
"return",
"the",
"correct",
"number",
"of",
"bytes",
"for",
"a",
"bit",
"string",
"defined",
"in",
"a",
"32",
"bit",
"constant"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.csiv2.common/src/com/ibm/ws/transport/iiop/asn1/DERBitString.java#L81-L100 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.csiv2.common/src/com/ibm/ws/transport/iiop/asn1/DERBitString.java | DERBitString.getInstance | public static DERBitString getInstance(
Object obj)
{
if (obj == null || obj instanceof DERBitString)
{
return (DERBitString)obj;
}
if (obj instanceof ASN1OctetString)
{
byte[] bytes = ((ASN1OctetString)obj).getOctets();
int padBits = bytes[0];
byte[] data = new byte[bytes.length - 1];
System.arraycopy(bytes, 1, data, 0, bytes.length - 1);
return new DERBitString(data, padBits);
}
if (obj instanceof ASN1TaggedObject)
{
return getInstance(((ASN1TaggedObject)obj).getObject());
}
throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
} | java | public static DERBitString getInstance(
Object obj)
{
if (obj == null || obj instanceof DERBitString)
{
return (DERBitString)obj;
}
if (obj instanceof ASN1OctetString)
{
byte[] bytes = ((ASN1OctetString)obj).getOctets();
int padBits = bytes[0];
byte[] data = new byte[bytes.length - 1];
System.arraycopy(bytes, 1, data, 0, bytes.length - 1);
return new DERBitString(data, padBits);
}
if (obj instanceof ASN1TaggedObject)
{
return getInstance(((ASN1TaggedObject)obj).getObject());
}
throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
} | [
"public",
"static",
"DERBitString",
"getInstance",
"(",
"Object",
"obj",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
"||",
"obj",
"instanceof",
"DERBitString",
")",
"{",
"return",
"(",
"DERBitString",
")",
"obj",
";",
"}",
"if",
"(",
"obj",
"instanceof",
"ASN1OctetString",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"(",
"(",
"ASN1OctetString",
")",
"obj",
")",
".",
"getOctets",
"(",
")",
";",
"int",
"padBits",
"=",
"bytes",
"[",
"0",
"]",
";",
"byte",
"[",
"]",
"data",
"=",
"new",
"byte",
"[",
"bytes",
".",
"length",
"-",
"1",
"]",
";",
"System",
".",
"arraycopy",
"(",
"bytes",
",",
"1",
",",
"data",
",",
"0",
",",
"bytes",
".",
"length",
"-",
"1",
")",
";",
"return",
"new",
"DERBitString",
"(",
"data",
",",
"padBits",
")",
";",
"}",
"if",
"(",
"obj",
"instanceof",
"ASN1TaggedObject",
")",
"{",
"return",
"getInstance",
"(",
"(",
"(",
"ASN1TaggedObject",
")",
"obj",
")",
".",
"getObject",
"(",
")",
")",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"illegal object in getInstance: \"",
"+",
"obj",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}"
] | return a Bit String from the passed in object
@exception IllegalArgumentException if the object cannot be converted. | [
"return",
"a",
"Bit",
"String",
"from",
"the",
"passed",
"in",
"object"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.csiv2.common/src/com/ibm/ws/transport/iiop/asn1/DERBitString.java#L107-L132 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/internal/BasicAuthAuthenticator.java | BasicAuthAuthenticator.handleBasicAuth | private AuthenticationResult handleBasicAuth(String inRealm, HttpServletRequest req, HttpServletResponse res) {
AuthenticationResult result = null;
String hdrValue = req.getHeader(BASIC_AUTH_HEADER_NAME);
if (hdrValue == null || !hdrValue.startsWith("Basic ")) {
result = new AuthenticationResult(AuthResult.SEND_401, inRealm, AuditEvent.CRED_TYPE_BASIC, null, AuditEvent.OUTCOME_CHALLENGE);
return result;
}
// Parse the username & password from the header.
String encoding = req.getHeader("Authorization-Encoding");
hdrValue = decodeBasicAuth(hdrValue.substring(6), encoding);
int idx = hdrValue.indexOf(':');
if (idx < 0) {
result = new AuthenticationResult(AuthResult.SEND_401, inRealm, AuditEvent.CRED_TYPE_BASIC, null, AuditEvent.OUTCOME_CHALLENGE);
return result;
}
String username = hdrValue.substring(0, idx);
String password = hdrValue.substring(idx + 1);
return basicAuthenticate(inRealm, username, password, req, res);
} | java | private AuthenticationResult handleBasicAuth(String inRealm, HttpServletRequest req, HttpServletResponse res) {
AuthenticationResult result = null;
String hdrValue = req.getHeader(BASIC_AUTH_HEADER_NAME);
if (hdrValue == null || !hdrValue.startsWith("Basic ")) {
result = new AuthenticationResult(AuthResult.SEND_401, inRealm, AuditEvent.CRED_TYPE_BASIC, null, AuditEvent.OUTCOME_CHALLENGE);
return result;
}
// Parse the username & password from the header.
String encoding = req.getHeader("Authorization-Encoding");
hdrValue = decodeBasicAuth(hdrValue.substring(6), encoding);
int idx = hdrValue.indexOf(':');
if (idx < 0) {
result = new AuthenticationResult(AuthResult.SEND_401, inRealm, AuditEvent.CRED_TYPE_BASIC, null, AuditEvent.OUTCOME_CHALLENGE);
return result;
}
String username = hdrValue.substring(0, idx);
String password = hdrValue.substring(idx + 1);
return basicAuthenticate(inRealm, username, password, req, res);
} | [
"private",
"AuthenticationResult",
"handleBasicAuth",
"(",
"String",
"inRealm",
",",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"res",
")",
"{",
"AuthenticationResult",
"result",
"=",
"null",
";",
"String",
"hdrValue",
"=",
"req",
".",
"getHeader",
"(",
"BASIC_AUTH_HEADER_NAME",
")",
";",
"if",
"(",
"hdrValue",
"==",
"null",
"||",
"!",
"hdrValue",
".",
"startsWith",
"(",
"\"Basic \"",
")",
")",
"{",
"result",
"=",
"new",
"AuthenticationResult",
"(",
"AuthResult",
".",
"SEND_401",
",",
"inRealm",
",",
"AuditEvent",
".",
"CRED_TYPE_BASIC",
",",
"null",
",",
"AuditEvent",
".",
"OUTCOME_CHALLENGE",
")",
";",
"return",
"result",
";",
"}",
"// Parse the username & password from the header.",
"String",
"encoding",
"=",
"req",
".",
"getHeader",
"(",
"\"Authorization-Encoding\"",
")",
";",
"hdrValue",
"=",
"decodeBasicAuth",
"(",
"hdrValue",
".",
"substring",
"(",
"6",
")",
",",
"encoding",
")",
";",
"int",
"idx",
"=",
"hdrValue",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"idx",
"<",
"0",
")",
"{",
"result",
"=",
"new",
"AuthenticationResult",
"(",
"AuthResult",
".",
"SEND_401",
",",
"inRealm",
",",
"AuditEvent",
".",
"CRED_TYPE_BASIC",
",",
"null",
",",
"AuditEvent",
".",
"OUTCOME_CHALLENGE",
")",
";",
"return",
"result",
";",
"}",
"String",
"username",
"=",
"hdrValue",
".",
"substring",
"(",
"0",
",",
"idx",
")",
";",
"String",
"password",
"=",
"hdrValue",
".",
"substring",
"(",
"idx",
"+",
"1",
")",
";",
"return",
"basicAuthenticate",
"(",
"inRealm",
",",
"username",
",",
"password",
",",
"req",
",",
"res",
")",
";",
"}"
] | handleBasicAuth generates AuthenticationResult
This routine invokes basicAuthenticate which also generates AuthenticationResult. | [
"handleBasicAuth",
"generates",
"AuthenticationResult",
"This",
"routine",
"invokes",
"basicAuthenticate",
"which",
"also",
"generates",
"AuthenticationResult",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/internal/BasicAuthAuthenticator.java#L95-L118 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/internal/BasicAuthAuthenticator.java | BasicAuthAuthenticator.getBasicAuthRealmName | protected String getBasicAuthRealmName(WebRequest webRequest) {
SecurityMetadata securityMetadata = webRequest.getSecurityMetadata();
if (securityMetadata != null) {
LoginConfiguration loginConfig = securityMetadata.getLoginConfiguration();
if (loginConfig != null && loginConfig.getRealmName() != null) {
return loginConfig.getRealmName();
}
if (config.getDisplayAuthenticationRealm()) {
return userRegistry.getRealm();
}
}
String realm = "defaultRealm";
return realm;
} | java | protected String getBasicAuthRealmName(WebRequest webRequest) {
SecurityMetadata securityMetadata = webRequest.getSecurityMetadata();
if (securityMetadata != null) {
LoginConfiguration loginConfig = securityMetadata.getLoginConfiguration();
if (loginConfig != null && loginConfig.getRealmName() != null) {
return loginConfig.getRealmName();
}
if (config.getDisplayAuthenticationRealm()) {
return userRegistry.getRealm();
}
}
String realm = "defaultRealm";
return realm;
} | [
"protected",
"String",
"getBasicAuthRealmName",
"(",
"WebRequest",
"webRequest",
")",
"{",
"SecurityMetadata",
"securityMetadata",
"=",
"webRequest",
".",
"getSecurityMetadata",
"(",
")",
";",
"if",
"(",
"securityMetadata",
"!=",
"null",
")",
"{",
"LoginConfiguration",
"loginConfig",
"=",
"securityMetadata",
".",
"getLoginConfiguration",
"(",
")",
";",
"if",
"(",
"loginConfig",
"!=",
"null",
"&&",
"loginConfig",
".",
"getRealmName",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"loginConfig",
".",
"getRealmName",
"(",
")",
";",
"}",
"if",
"(",
"config",
".",
"getDisplayAuthenticationRealm",
"(",
")",
")",
"{",
"return",
"userRegistry",
".",
"getRealm",
"(",
")",
";",
"}",
"}",
"String",
"realm",
"=",
"\"defaultRealm\"",
";",
"return",
"realm",
";",
"}"
] | Return a realm name if it's defined in the web.xml file. If it's not defined in the web.xml
and displayAuthenticationRealm is set to true, then return the userRegistry realm. Otherwise return
the realm as "Default Realm".
@param webRequest
@return realm | [
"Return",
"a",
"realm",
"name",
"if",
"it",
"s",
"defined",
"in",
"the",
"web",
".",
"xml",
"file",
".",
"If",
"it",
"s",
"not",
"defined",
"in",
"the",
"web",
".",
"xml",
"and",
"displayAuthenticationRealm",
"is",
"set",
"to",
"true",
"then",
"return",
"the",
"userRegistry",
"realm",
".",
"Otherwise",
"return",
"the",
"realm",
"as",
"Default",
"Realm",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/internal/BasicAuthAuthenticator.java#L162-L175 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/internal/BasicAuthAuthenticator.java | BasicAuthAuthenticator.decodeBasicAuth | @Sensitive
protected String decodeBasicAuth(String data, String encoding) {
String output = "";
byte decodedByte[] = null;
decodedByte = Base64Coder.base64DecodeString(data);
if (decodedByte != null && decodedByte.length > 0) {
boolean decoded = false;
if (encoding != null) {
try {
output = new String(decodedByte, encoding);
decoded = true;
} catch (Exception e) {
// fall back not to use encoding..
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "An exception is caught using the encoder: " + encoding + ". The exception is: " + e.getMessage());
}
}
}
if (!decoded) {
output = new String(decodedByte);
}
}
return output;
} | java | @Sensitive
protected String decodeBasicAuth(String data, String encoding) {
String output = "";
byte decodedByte[] = null;
decodedByte = Base64Coder.base64DecodeString(data);
if (decodedByte != null && decodedByte.length > 0) {
boolean decoded = false;
if (encoding != null) {
try {
output = new String(decodedByte, encoding);
decoded = true;
} catch (Exception e) {
// fall back not to use encoding..
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "An exception is caught using the encoder: " + encoding + ". The exception is: " + e.getMessage());
}
}
}
if (!decoded) {
output = new String(decodedByte);
}
}
return output;
} | [
"@",
"Sensitive",
"protected",
"String",
"decodeBasicAuth",
"(",
"String",
"data",
",",
"String",
"encoding",
")",
"{",
"String",
"output",
"=",
"\"\"",
";",
"byte",
"decodedByte",
"[",
"]",
"=",
"null",
";",
"decodedByte",
"=",
"Base64Coder",
".",
"base64DecodeString",
"(",
"data",
")",
";",
"if",
"(",
"decodedByte",
"!=",
"null",
"&&",
"decodedByte",
".",
"length",
">",
"0",
")",
"{",
"boolean",
"decoded",
"=",
"false",
";",
"if",
"(",
"encoding",
"!=",
"null",
")",
"{",
"try",
"{",
"output",
"=",
"new",
"String",
"(",
"decodedByte",
",",
"encoding",
")",
";",
"decoded",
"=",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// fall back not to use encoding..",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"An exception is caught using the encoder: \"",
"+",
"encoding",
"+",
"\". The exception is: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"decoded",
")",
"{",
"output",
"=",
"new",
"String",
"(",
"decodedByte",
")",
";",
"}",
"}",
"return",
"output",
";",
"}"
] | 2. This method intentionally returns empty string in case of error. With that, a caller doesn't need to check null object prior to introspect it. | [
"2",
".",
"This",
"method",
"intentionally",
"returns",
"empty",
"string",
"in",
"case",
"of",
"error",
".",
"With",
"that",
"a",
"caller",
"doesn",
"t",
"need",
"to",
"check",
"null",
"object",
"prior",
"to",
"introspect",
"it",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/internal/BasicAuthAuthenticator.java#L180-L203 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/FixDependencyChecker.java | FixDependencyChecker.isUninstallable | public static boolean isUninstallable(Set<IFixInfo> installedFixes, IFixInfo fixToBeUninstalled) {
if (Boolean.valueOf(System.getenv(S_DISABLE)).booleanValue()) {
return true;
}
if (fixToBeUninstalled != null) {
for (IFixInfo fix : installedFixes) {
if (!(fixToBeUninstalled.getId().equals(fix.getId())) && !confirmNoFileConflicts(fixToBeUninstalled.getUpdates().getFiles(), fix.getUpdates().getFiles())) {
if (!isSupersededBy(fix.getResolves().getProblems(), fixToBeUninstalled.getResolves().getProblems())) {
return false;
}
}
}
return true;
}
return false;
} | java | public static boolean isUninstallable(Set<IFixInfo> installedFixes, IFixInfo fixToBeUninstalled) {
if (Boolean.valueOf(System.getenv(S_DISABLE)).booleanValue()) {
return true;
}
if (fixToBeUninstalled != null) {
for (IFixInfo fix : installedFixes) {
if (!(fixToBeUninstalled.getId().equals(fix.getId())) && !confirmNoFileConflicts(fixToBeUninstalled.getUpdates().getFiles(), fix.getUpdates().getFiles())) {
if (!isSupersededBy(fix.getResolves().getProblems(), fixToBeUninstalled.getResolves().getProblems())) {
return false;
}
}
}
return true;
}
return false;
} | [
"public",
"static",
"boolean",
"isUninstallable",
"(",
"Set",
"<",
"IFixInfo",
">",
"installedFixes",
",",
"IFixInfo",
"fixToBeUninstalled",
")",
"{",
"if",
"(",
"Boolean",
".",
"valueOf",
"(",
"System",
".",
"getenv",
"(",
"S_DISABLE",
")",
")",
".",
"booleanValue",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"fixToBeUninstalled",
"!=",
"null",
")",
"{",
"for",
"(",
"IFixInfo",
"fix",
":",
"installedFixes",
")",
"{",
"if",
"(",
"!",
"(",
"fixToBeUninstalled",
".",
"getId",
"(",
")",
".",
"equals",
"(",
"fix",
".",
"getId",
"(",
")",
")",
")",
"&&",
"!",
"confirmNoFileConflicts",
"(",
"fixToBeUninstalled",
".",
"getUpdates",
"(",
")",
".",
"getFiles",
"(",
")",
",",
"fix",
".",
"getUpdates",
"(",
")",
".",
"getFiles",
"(",
")",
")",
")",
"{",
"if",
"(",
"!",
"isSupersededBy",
"(",
"fix",
".",
"getResolves",
"(",
")",
".",
"getProblems",
"(",
")",
",",
"fixToBeUninstalled",
".",
"getResolves",
"(",
")",
".",
"getProblems",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Return true if fixToBeUninstalled can be uninstalled. fixToBeUninstalled can only be uninstalled if there are no file conflicts with other fixes in the installedFixes Set
that supersedes fixToBeUninstalled
@param installedFixes The set of fixes that is already installed, the set does not include the fixToBeUninstalled
@param fixToBeUninstalled The fix to be uninstalled
@return Return true if the fixToBeUninstalled can be uninstalled. False otherwise. | [
"Return",
"true",
"if",
"fixToBeUninstalled",
"can",
"be",
"uninstalled",
".",
"fixToBeUninstalled",
"can",
"only",
"be",
"uninstalled",
"if",
"there",
"are",
"no",
"file",
"conflicts",
"with",
"other",
"fixes",
"in",
"the",
"installedFixes",
"Set",
"that",
"supersedes",
"fixToBeUninstalled"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/FixDependencyChecker.java#L46-L63 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/FixDependencyChecker.java | FixDependencyChecker.isUninstallable | public boolean isUninstallable(UninstallAsset uninstallAsset, Set<IFixInfo> installedFixes, List<UninstallAsset> uninstallAssets) {
if (Boolean.valueOf(System.getenv(S_DISABLE)).booleanValue()) {
return true;
}
IFixInfo fixToBeUninstalled = uninstallAsset.getIFixInfo();
for (IFixInfo fix : installedFixes) {
if (!(fixToBeUninstalled.getId().equals(fix.getId()))) {
if ((!confirmNoFileConflicts(fixToBeUninstalled.getUpdates().getFiles(), fix.getUpdates().getFiles())) &&
(!isSupersededBy(fix.getResolves().getProblems(), fixToBeUninstalled.getResolves().getProblems())))
if (!isToBeUninstalled(fix.getId(), uninstallAssets))
return false;
}
}
return true;
} | java | public boolean isUninstallable(UninstallAsset uninstallAsset, Set<IFixInfo> installedFixes, List<UninstallAsset> uninstallAssets) {
if (Boolean.valueOf(System.getenv(S_DISABLE)).booleanValue()) {
return true;
}
IFixInfo fixToBeUninstalled = uninstallAsset.getIFixInfo();
for (IFixInfo fix : installedFixes) {
if (!(fixToBeUninstalled.getId().equals(fix.getId()))) {
if ((!confirmNoFileConflicts(fixToBeUninstalled.getUpdates().getFiles(), fix.getUpdates().getFiles())) &&
(!isSupersededBy(fix.getResolves().getProblems(), fixToBeUninstalled.getResolves().getProblems())))
if (!isToBeUninstalled(fix.getId(), uninstallAssets))
return false;
}
}
return true;
} | [
"public",
"boolean",
"isUninstallable",
"(",
"UninstallAsset",
"uninstallAsset",
",",
"Set",
"<",
"IFixInfo",
">",
"installedFixes",
",",
"List",
"<",
"UninstallAsset",
">",
"uninstallAssets",
")",
"{",
"if",
"(",
"Boolean",
".",
"valueOf",
"(",
"System",
".",
"getenv",
"(",
"S_DISABLE",
")",
")",
".",
"booleanValue",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"IFixInfo",
"fixToBeUninstalled",
"=",
"uninstallAsset",
".",
"getIFixInfo",
"(",
")",
";",
"for",
"(",
"IFixInfo",
"fix",
":",
"installedFixes",
")",
"{",
"if",
"(",
"!",
"(",
"fixToBeUninstalled",
".",
"getId",
"(",
")",
".",
"equals",
"(",
"fix",
".",
"getId",
"(",
")",
")",
")",
")",
"{",
"if",
"(",
"(",
"!",
"confirmNoFileConflicts",
"(",
"fixToBeUninstalled",
".",
"getUpdates",
"(",
")",
".",
"getFiles",
"(",
")",
",",
"fix",
".",
"getUpdates",
"(",
")",
".",
"getFiles",
"(",
")",
")",
")",
"&&",
"(",
"!",
"isSupersededBy",
"(",
"fix",
".",
"getResolves",
"(",
")",
".",
"getProblems",
"(",
")",
",",
"fixToBeUninstalled",
".",
"getResolves",
"(",
")",
".",
"getProblems",
"(",
")",
")",
")",
")",
"if",
"(",
"!",
"isToBeUninstalled",
"(",
"fix",
".",
"getId",
"(",
")",
",",
"uninstallAssets",
")",
")",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Verfiy whether the fix is uninstallable and there is no other installed
fix still require this feature.
@param uninstallAsset fix to be uninstalled
@param installedFixes installed fixes
@param uninstallAssets the list of fixes that is to be uninstalled
@return the true if there is no fix that depends on the uninstall asset. return false otherwise | [
"Verfiy",
"whether",
"the",
"fix",
"is",
"uninstallable",
"and",
"there",
"is",
"no",
"other",
"installed",
"fix",
"still",
"require",
"this",
"feature",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/FixDependencyChecker.java#L74-L90 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/FixDependencyChecker.java | FixDependencyChecker.fixRequiredByFeature | public static ArrayList<String> fixRequiredByFeature(String fixApar, Map<String, ProvisioningFeatureDefinition> installedFeatures) {
ArrayList<String> dependencies = new ArrayList<String>();
for (ProvisioningFeatureDefinition fd : installedFeatures.values()) {
String requireFixes = fd.getHeader("IBM-Require-Fix");
if (requireFixes != null && requireFixes.length() > 0) {
String[] apars = requireFixes.split(";");
for (String apar : apars) {
if (apar.trim().equals(fixApar.trim())) {
dependencies.add(apar);
}
}
}
}
if (dependencies.isEmpty())
return null;
return dependencies;
} | java | public static ArrayList<String> fixRequiredByFeature(String fixApar, Map<String, ProvisioningFeatureDefinition> installedFeatures) {
ArrayList<String> dependencies = new ArrayList<String>();
for (ProvisioningFeatureDefinition fd : installedFeatures.values()) {
String requireFixes = fd.getHeader("IBM-Require-Fix");
if (requireFixes != null && requireFixes.length() > 0) {
String[] apars = requireFixes.split(";");
for (String apar : apars) {
if (apar.trim().equals(fixApar.trim())) {
dependencies.add(apar);
}
}
}
}
if (dependencies.isEmpty())
return null;
return dependencies;
} | [
"public",
"static",
"ArrayList",
"<",
"String",
">",
"fixRequiredByFeature",
"(",
"String",
"fixApar",
",",
"Map",
"<",
"String",
",",
"ProvisioningFeatureDefinition",
">",
"installedFeatures",
")",
"{",
"ArrayList",
"<",
"String",
">",
"dependencies",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"ProvisioningFeatureDefinition",
"fd",
":",
"installedFeatures",
".",
"values",
"(",
")",
")",
"{",
"String",
"requireFixes",
"=",
"fd",
".",
"getHeader",
"(",
"\"IBM-Require-Fix\"",
")",
";",
"if",
"(",
"requireFixes",
"!=",
"null",
"&&",
"requireFixes",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"String",
"[",
"]",
"apars",
"=",
"requireFixes",
".",
"split",
"(",
"\";\"",
")",
";",
"for",
"(",
"String",
"apar",
":",
"apars",
")",
"{",
"if",
"(",
"apar",
".",
"trim",
"(",
")",
".",
"equals",
"(",
"fixApar",
".",
"trim",
"(",
")",
")",
")",
"{",
"dependencies",
".",
"add",
"(",
"apar",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"dependencies",
".",
"isEmpty",
"(",
")",
")",
"return",
"null",
";",
"return",
"dependencies",
";",
"}"
] | Determine the fix apar is required by one of the installed features
@param fixApar fix apar
@param installedFeatures installed features
@return true if the fix apar is required by one of the installed features, otherwise, return false. | [
"Determine",
"the",
"fix",
"apar",
"is",
"required",
"by",
"one",
"of",
"the",
"installed",
"features"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/FixDependencyChecker.java#L116-L132 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/FixDependencyChecker.java | FixDependencyChecker.determineOrder | public List<UninstallAsset> determineOrder(List<UninstallAsset> list) {
if (list != null) {
List<FixDependencyComparator> fixCompareList = new ArrayList<FixDependencyComparator>();
// Initialize the feature comparator
for (UninstallAsset asset : list) {
fixCompareList.add(new FixDependencyComparator(asset.getIFixInfo()));
}
// Sort the feature list
Collections.sort(fixCompareList, new FixDependencyComparator());
List<UninstallAsset> newList = new ArrayList<UninstallAsset>();
for (FixDependencyComparator f : fixCompareList) {
newList.add(new UninstallAsset(f.getIfixInfo()));
}
return newList;
}
return list;
} | java | public List<UninstallAsset> determineOrder(List<UninstallAsset> list) {
if (list != null) {
List<FixDependencyComparator> fixCompareList = new ArrayList<FixDependencyComparator>();
// Initialize the feature comparator
for (UninstallAsset asset : list) {
fixCompareList.add(new FixDependencyComparator(asset.getIFixInfo()));
}
// Sort the feature list
Collections.sort(fixCompareList, new FixDependencyComparator());
List<UninstallAsset> newList = new ArrayList<UninstallAsset>();
for (FixDependencyComparator f : fixCompareList) {
newList.add(new UninstallAsset(f.getIfixInfo()));
}
return newList;
}
return list;
} | [
"public",
"List",
"<",
"UninstallAsset",
">",
"determineOrder",
"(",
"List",
"<",
"UninstallAsset",
">",
"list",
")",
"{",
"if",
"(",
"list",
"!=",
"null",
")",
"{",
"List",
"<",
"FixDependencyComparator",
">",
"fixCompareList",
"=",
"new",
"ArrayList",
"<",
"FixDependencyComparator",
">",
"(",
")",
";",
"// Initialize the feature comparator",
"for",
"(",
"UninstallAsset",
"asset",
":",
"list",
")",
"{",
"fixCompareList",
".",
"add",
"(",
"new",
"FixDependencyComparator",
"(",
"asset",
".",
"getIFixInfo",
"(",
")",
")",
")",
";",
"}",
"// Sort the feature list",
"Collections",
".",
"sort",
"(",
"fixCompareList",
",",
"new",
"FixDependencyComparator",
"(",
")",
")",
";",
"List",
"<",
"UninstallAsset",
">",
"newList",
"=",
"new",
"ArrayList",
"<",
"UninstallAsset",
">",
"(",
")",
";",
"for",
"(",
"FixDependencyComparator",
"f",
":",
"fixCompareList",
")",
"{",
"newList",
".",
"add",
"(",
"new",
"UninstallAsset",
"(",
"f",
".",
"getIfixInfo",
"(",
")",
")",
")",
";",
"}",
"return",
"newList",
";",
"}",
"return",
"list",
";",
"}"
] | Determine the order of the fixes according to their dependency
@param list list of the fixes
@return the sorted fixes list according to the fix dependency | [
"Determine",
"the",
"order",
"of",
"the",
"fixes",
"according",
"to",
"their",
"dependency"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/FixDependencyChecker.java#L140-L156 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/FixDependencyChecker.java | FixDependencyChecker.isSupersededBy | private static boolean isSupersededBy(List<Problem> apars1, List<Problem> apars2) {
boolean result = true;
// Now iterate over the current list of problems, and see if the incoming IFixInfo contains all of the problems from this IfixInfo.
// If it does then return true, to indicate that this IFixInfo object has been superseded.
for (Iterator<Problem> iter1 = apars1.iterator(); iter1.hasNext();) {
boolean currAparMatch = false;
Problem currApar1 = iter1.next();
for (Iterator<Problem> iter2 = apars2.iterator(); iter2.hasNext();) {
Problem currApar2 = iter2.next();
if (currApar1.getDisplayId().equals(currApar2.getDisplayId())) {
currAparMatch = true;
}
}
if (!currAparMatch)
result = false;
}
return result;
} | java | private static boolean isSupersededBy(List<Problem> apars1, List<Problem> apars2) {
boolean result = true;
// Now iterate over the current list of problems, and see if the incoming IFixInfo contains all of the problems from this IfixInfo.
// If it does then return true, to indicate that this IFixInfo object has been superseded.
for (Iterator<Problem> iter1 = apars1.iterator(); iter1.hasNext();) {
boolean currAparMatch = false;
Problem currApar1 = iter1.next();
for (Iterator<Problem> iter2 = apars2.iterator(); iter2.hasNext();) {
Problem currApar2 = iter2.next();
if (currApar1.getDisplayId().equals(currApar2.getDisplayId())) {
currAparMatch = true;
}
}
if (!currAparMatch)
result = false;
}
return result;
} | [
"private",
"static",
"boolean",
"isSupersededBy",
"(",
"List",
"<",
"Problem",
">",
"apars1",
",",
"List",
"<",
"Problem",
">",
"apars2",
")",
"{",
"boolean",
"result",
"=",
"true",
";",
"// Now iterate over the current list of problems, and see if the incoming IFixInfo contains all of the problems from this IfixInfo.",
"// If it does then return true, to indicate that this IFixInfo object has been superseded.",
"for",
"(",
"Iterator",
"<",
"Problem",
">",
"iter1",
"=",
"apars1",
".",
"iterator",
"(",
")",
";",
"iter1",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"boolean",
"currAparMatch",
"=",
"false",
";",
"Problem",
"currApar1",
"=",
"iter1",
".",
"next",
"(",
")",
";",
"for",
"(",
"Iterator",
"<",
"Problem",
">",
"iter2",
"=",
"apars2",
".",
"iterator",
"(",
")",
";",
"iter2",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Problem",
"currApar2",
"=",
"iter2",
".",
"next",
"(",
")",
";",
"if",
"(",
"currApar1",
".",
"getDisplayId",
"(",
")",
".",
"equals",
"(",
"currApar2",
".",
"getDisplayId",
"(",
")",
")",
")",
"{",
"currAparMatch",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"currAparMatch",
")",
"result",
"=",
"false",
";",
"}",
"return",
"result",
";",
"}"
] | Returns if the apars list apars1 is superseded by apars2. Apars1 is superseded by apars2 if all the apars in apars1 is also included in apars2
@param apars1 Fix to check
@param apars2
@return Returns true if apars list apars1 is superseded by apars2. Else return false. | [
"Returns",
"if",
"the",
"apars",
"list",
"apars1",
"is",
"superseded",
"by",
"apars2",
".",
"Apars1",
"is",
"superseded",
"by",
"apars2",
"if",
"all",
"the",
"apars",
"in",
"apars1",
"is",
"also",
"included",
"in",
"apars2"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/FixDependencyChecker.java#L165-L184 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/FixDependencyChecker.java | FixDependencyChecker.confirmNoFileConflicts | private static boolean confirmNoFileConflicts(Set<UpdatedFile> updatedFiles1, Set<UpdatedFile> updatedFiles2) {
for (Iterator<UpdatedFile> iter1 = updatedFiles1.iterator(); iter1.hasNext();) {
UpdatedFile currFile1 = iter1.next();
for (Iterator<UpdatedFile> iter2 = updatedFiles2.iterator(); iter2.hasNext();) {
UpdatedFile currFile2 = iter2.next();
if (currFile1.getId().equals(currFile2.getId())) {
return false;
}
}
}
return true;
} | java | private static boolean confirmNoFileConflicts(Set<UpdatedFile> updatedFiles1, Set<UpdatedFile> updatedFiles2) {
for (Iterator<UpdatedFile> iter1 = updatedFiles1.iterator(); iter1.hasNext();) {
UpdatedFile currFile1 = iter1.next();
for (Iterator<UpdatedFile> iter2 = updatedFiles2.iterator(); iter2.hasNext();) {
UpdatedFile currFile2 = iter2.next();
if (currFile1.getId().equals(currFile2.getId())) {
return false;
}
}
}
return true;
} | [
"private",
"static",
"boolean",
"confirmNoFileConflicts",
"(",
"Set",
"<",
"UpdatedFile",
">",
"updatedFiles1",
",",
"Set",
"<",
"UpdatedFile",
">",
"updatedFiles2",
")",
"{",
"for",
"(",
"Iterator",
"<",
"UpdatedFile",
">",
"iter1",
"=",
"updatedFiles1",
".",
"iterator",
"(",
")",
";",
"iter1",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"UpdatedFile",
"currFile1",
"=",
"iter1",
".",
"next",
"(",
")",
";",
"for",
"(",
"Iterator",
"<",
"UpdatedFile",
">",
"iter2",
"=",
"updatedFiles2",
".",
"iterator",
"(",
")",
";",
"iter2",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"UpdatedFile",
"currFile2",
"=",
"iter2",
".",
"next",
"(",
")",
";",
"if",
"(",
"currFile1",
".",
"getId",
"(",
")",
".",
"equals",
"(",
"currFile2",
".",
"getId",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Confirms that UpdatedFile lists does not contain any common files
@param updatedFiles1
@param updatedFiles2
@return Return true if there are no conflicts and return false otherwise | [
"Confirms",
"that",
"UpdatedFile",
"lists",
"does",
"not",
"contain",
"any",
"common",
"files"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/FixDependencyChecker.java#L193-L205 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java | CacheOnDisk.close | @Override
public void close(boolean deleteProgressFile) {
final String methodName = "close()";
traceDebug(methodName, "cacheName=" + this.cacheName + " deleteProgressFile=" + deleteProgressFile);
if (deleteProgressFile) { // 316654
// remove the InProgress (dummy) file when close
deleteInProgressFile();
}
try {
htod.close();
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.close", "574", this);
traceDebug(methodName, "cacheName=" + this.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
}
} | java | @Override
public void close(boolean deleteProgressFile) {
final String methodName = "close()";
traceDebug(methodName, "cacheName=" + this.cacheName + " deleteProgressFile=" + deleteProgressFile);
if (deleteProgressFile) { // 316654
// remove the InProgress (dummy) file when close
deleteInProgressFile();
}
try {
htod.close();
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.close", "574", this);
traceDebug(methodName, "cacheName=" + this.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
}
} | [
"@",
"Override",
"public",
"void",
"close",
"(",
"boolean",
"deleteProgressFile",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"close()\"",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"this",
".",
"cacheName",
"+",
"\" deleteProgressFile=\"",
"+",
"deleteProgressFile",
")",
";",
"if",
"(",
"deleteProgressFile",
")",
"{",
"// 316654",
"// remove the InProgress (dummy) file when close",
"deleteInProgressFile",
"(",
")",
";",
"}",
"try",
"{",
"htod",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"t",
",",
"\"com.ibm.ws.cache.CacheOnDisk.close\"",
",",
"\"574\"",
",",
"this",
")",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"this",
".",
"cacheName",
"+",
"\"\\nException: \"",
"+",
"ExceptionUtility",
".",
"getStackTrace",
"(",
"t",
")",
")",
";",
"}",
"}"
] | Call this method to close the disk file manager and operation. | [
"Call",
"this",
"method",
"to",
"close",
"the",
"disk",
"file",
"manager",
"and",
"operation",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L608-L622 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java | CacheOnDisk.writeAuxiliaryDepTables | @Override
public int writeAuxiliaryDepTables() {
int returnCode = htod.writeAuxiliaryDepTables();
if (returnCode == HTODDynacache.DISK_EXCEPTION) {
stopOnError(this.htod.diskCacheException);
} else {
updatePropertyFile();
}
return returnCode;
} | java | @Override
public int writeAuxiliaryDepTables() {
int returnCode = htod.writeAuxiliaryDepTables();
if (returnCode == HTODDynacache.DISK_EXCEPTION) {
stopOnError(this.htod.diskCacheException);
} else {
updatePropertyFile();
}
return returnCode;
} | [
"@",
"Override",
"public",
"int",
"writeAuxiliaryDepTables",
"(",
")",
"{",
"int",
"returnCode",
"=",
"htod",
".",
"writeAuxiliaryDepTables",
"(",
")",
";",
"if",
"(",
"returnCode",
"==",
"HTODDynacache",
".",
"DISK_EXCEPTION",
")",
"{",
"stopOnError",
"(",
"this",
".",
"htod",
".",
"diskCacheException",
")",
";",
"}",
"else",
"{",
"updatePropertyFile",
"(",
")",
";",
"}",
"return",
"returnCode",
";",
"}"
] | Call this method to offload auxiliary dependency tables to the disk and update property file. | [
"Call",
"this",
"method",
"to",
"offload",
"auxiliary",
"dependency",
"tables",
"to",
"the",
"disk",
"and",
"update",
"property",
"file",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L627-L636 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java | CacheOnDisk.readLastScanFile | private void readLastScanFile() {
final String methodName = "readLastScanFile()";
final File f = new File(lastScanFileName);
traceDebug(methodName, "cacheName=" + this.cacheName);
if (f.exists()) {
final CacheOnDisk cod = this;
AccessController.doPrivileged(new PrivilegedAction() {
@Override
public Object run() {
FileInputStream fis = null;
ObjectInputStream ois = null;
try {
fis = new FileInputStream(f);
ois = new ObjectInputStream(fis);
cod.lastScanTime = ois.readLong();
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.readLastScanFile", "611", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
} finally {
try {
if (ois != null) {
ois.close();
}
if (fis != null) {
fis.close();
}
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.readLastScanFile", "622", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
}
}
return null;
}
});
}
} | java | private void readLastScanFile() {
final String methodName = "readLastScanFile()";
final File f = new File(lastScanFileName);
traceDebug(methodName, "cacheName=" + this.cacheName);
if (f.exists()) {
final CacheOnDisk cod = this;
AccessController.doPrivileged(new PrivilegedAction() {
@Override
public Object run() {
FileInputStream fis = null;
ObjectInputStream ois = null;
try {
fis = new FileInputStream(f);
ois = new ObjectInputStream(fis);
cod.lastScanTime = ois.readLong();
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.readLastScanFile", "611", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
} finally {
try {
if (ois != null) {
ois.close();
}
if (fis != null) {
fis.close();
}
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.readLastScanFile", "622", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
}
}
return null;
}
});
}
} | [
"private",
"void",
"readLastScanFile",
"(",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"readLastScanFile()\"",
";",
"final",
"File",
"f",
"=",
"new",
"File",
"(",
"lastScanFileName",
")",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"this",
".",
"cacheName",
")",
";",
"if",
"(",
"f",
".",
"exists",
"(",
")",
")",
"{",
"final",
"CacheOnDisk",
"cod",
"=",
"this",
";",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedAction",
"(",
")",
"{",
"@",
"Override",
"public",
"Object",
"run",
"(",
")",
"{",
"FileInputStream",
"fis",
"=",
"null",
";",
"ObjectInputStream",
"ois",
"=",
"null",
";",
"try",
"{",
"fis",
"=",
"new",
"FileInputStream",
"(",
"f",
")",
";",
"ois",
"=",
"new",
"ObjectInputStream",
"(",
"fis",
")",
";",
"cod",
".",
"lastScanTime",
"=",
"ois",
".",
"readLong",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"t",
",",
"\"com.ibm.ws.cache.CacheOnDisk.readLastScanFile\"",
",",
"\"611\"",
",",
"cod",
")",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"cod",
".",
"cacheName",
"+",
"\"\\nException: \"",
"+",
"ExceptionUtility",
".",
"getStackTrace",
"(",
"t",
")",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"ois",
"!=",
"null",
")",
"{",
"ois",
".",
"close",
"(",
")",
";",
"}",
"if",
"(",
"fis",
"!=",
"null",
")",
"{",
"fis",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"t",
",",
"\"com.ibm.ws.cache.CacheOnDisk.readLastScanFile\"",
",",
"\"622\"",
",",
"cod",
")",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"cod",
".",
"cacheName",
"+",
"\"\\nException: \"",
"+",
"ExceptionUtility",
".",
"getStackTrace",
"(",
"t",
")",
")",
";",
"}",
"}",
"return",
"null",
";",
"}",
"}",
")",
";",
"}",
"}"
] | Call this method to read the timestamp of the last scan in Last Scan file. | [
"Call",
"this",
"method",
"to",
"read",
"the",
"timestamp",
"of",
"the",
"last",
"scan",
"in",
"Last",
"Scan",
"file",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L641-L676 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java | CacheOnDisk.updateLastScanFile | protected void updateLastScanFile() {
final String methodName = "updateLastScanFile()";
final File f = new File(lastScanFileName);
final CacheOnDisk cod = this;
traceDebug(methodName, "cacheName=" + this.cacheName);
AccessController.doPrivileged(new PrivilegedAction() {
@Override
public Object run() {
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try {
fos = new FileOutputStream(f);
oos = new ObjectOutputStream(fos);
oos.writeLong(System.currentTimeMillis());
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.updateLastScanFile", "650", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
} finally {
try {
if (oos != null) {
oos.close();
}
if (fos != null) {
fos.close();
}
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.updateLastScanFile", "661", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
}
}
return null;
}
});
} | java | protected void updateLastScanFile() {
final String methodName = "updateLastScanFile()";
final File f = new File(lastScanFileName);
final CacheOnDisk cod = this;
traceDebug(methodName, "cacheName=" + this.cacheName);
AccessController.doPrivileged(new PrivilegedAction() {
@Override
public Object run() {
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try {
fos = new FileOutputStream(f);
oos = new ObjectOutputStream(fos);
oos.writeLong(System.currentTimeMillis());
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.updateLastScanFile", "650", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
} finally {
try {
if (oos != null) {
oos.close();
}
if (fos != null) {
fos.close();
}
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.updateLastScanFile", "661", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
}
}
return null;
}
});
} | [
"protected",
"void",
"updateLastScanFile",
"(",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"updateLastScanFile()\"",
";",
"final",
"File",
"f",
"=",
"new",
"File",
"(",
"lastScanFileName",
")",
";",
"final",
"CacheOnDisk",
"cod",
"=",
"this",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"this",
".",
"cacheName",
")",
";",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedAction",
"(",
")",
"{",
"@",
"Override",
"public",
"Object",
"run",
"(",
")",
"{",
"FileOutputStream",
"fos",
"=",
"null",
";",
"ObjectOutputStream",
"oos",
"=",
"null",
";",
"try",
"{",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"f",
")",
";",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"fos",
")",
";",
"oos",
".",
"writeLong",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"t",
",",
"\"com.ibm.ws.cache.CacheOnDisk.updateLastScanFile\"",
",",
"\"650\"",
",",
"cod",
")",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"cod",
".",
"cacheName",
"+",
"\"\\nException: \"",
"+",
"ExceptionUtility",
".",
"getStackTrace",
"(",
"t",
")",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"oos",
"!=",
"null",
")",
"{",
"oos",
".",
"close",
"(",
")",
";",
"}",
"if",
"(",
"fos",
"!=",
"null",
")",
"{",
"fos",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"t",
",",
"\"com.ibm.ws.cache.CacheOnDisk.updateLastScanFile\"",
",",
"\"661\"",
",",
"cod",
")",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"cod",
".",
"cacheName",
"+",
"\"\\nException: \"",
"+",
"ExceptionUtility",
".",
"getStackTrace",
"(",
"t",
")",
")",
";",
"}",
"}",
"return",
"null",
";",
"}",
"}",
")",
";",
"}"
] | Call this method to update the timestamp of the last scan in Last Scan file. | [
"Call",
"this",
"method",
"to",
"update",
"the",
"timestamp",
"of",
"the",
"last",
"scan",
"in",
"Last",
"Scan",
"file",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L681-L714 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java | CacheOnDisk.deletePropertyFile | private void deletePropertyFile() {
final String methodName = "deletePropertyFile()";
final File f = new File(htodPropertyFileName);
final CacheOnDisk cod = this;
traceDebug(methodName, "cacheName=" + this.cacheName);
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
f.delete();
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.deletePropertyFile", "883", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
}
return null;
}
});
} | java | private void deletePropertyFile() {
final String methodName = "deletePropertyFile()";
final File f = new File(htodPropertyFileName);
final CacheOnDisk cod = this;
traceDebug(methodName, "cacheName=" + this.cacheName);
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
f.delete();
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.deletePropertyFile", "883", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
}
return null;
}
});
} | [
"private",
"void",
"deletePropertyFile",
"(",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"deletePropertyFile()\"",
";",
"final",
"File",
"f",
"=",
"new",
"File",
"(",
"htodPropertyFileName",
")",
";",
"final",
"CacheOnDisk",
"cod",
"=",
"this",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"this",
".",
"cacheName",
")",
";",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedAction",
"(",
")",
"{",
"public",
"Object",
"run",
"(",
")",
"{",
"try",
"{",
"f",
".",
"delete",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"t",
",",
"\"com.ibm.ws.cache.CacheOnDisk.deletePropertyFile\"",
",",
"\"883\"",
",",
"cod",
")",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"cod",
".",
"cacheName",
"+",
"\"\\nException: \"",
"+",
"ExceptionUtility",
".",
"getStackTrace",
"(",
"t",
")",
")",
";",
"}",
"return",
"null",
";",
"}",
"}",
")",
";",
"}"
] | Call this method to delete the HTOD property file. | [
"Call",
"this",
"method",
"to",
"delete",
"the",
"HTOD",
"property",
"file",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L916-L932 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java | CacheOnDisk.deleteDiskCacheFiles | public void deleteDiskCacheFiles() {
final String methodName = "deleteDiskCacheFiles()";
final File f = new File(swapDirPath);
final CacheOnDisk cod = this;
traceDebug(methodName, "cacheName=" + this.cacheName);
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
// delete files
File fl[] = f.listFiles();
for (int i = 0; i < fl.length; i++) {
try {
fl[i].delete();
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.deleteDiskCacheFiles", "908", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
}
}
return null;
}
});
} | java | public void deleteDiskCacheFiles() {
final String methodName = "deleteDiskCacheFiles()";
final File f = new File(swapDirPath);
final CacheOnDisk cod = this;
traceDebug(methodName, "cacheName=" + this.cacheName);
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
// delete files
File fl[] = f.listFiles();
for (int i = 0; i < fl.length; i++) {
try {
fl[i].delete();
} catch (Throwable t) {
com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.deleteDiskCacheFiles", "908", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
}
}
return null;
}
});
} | [
"public",
"void",
"deleteDiskCacheFiles",
"(",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"deleteDiskCacheFiles()\"",
";",
"final",
"File",
"f",
"=",
"new",
"File",
"(",
"swapDirPath",
")",
";",
"final",
"CacheOnDisk",
"cod",
"=",
"this",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"this",
".",
"cacheName",
")",
";",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedAction",
"(",
")",
"{",
"public",
"Object",
"run",
"(",
")",
"{",
"// delete files",
"File",
"fl",
"[",
"]",
"=",
"f",
".",
"listFiles",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fl",
".",
"length",
";",
"i",
"++",
")",
"{",
"try",
"{",
"fl",
"[",
"i",
"]",
".",
"delete",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"t",
",",
"\"com.ibm.ws.cache.CacheOnDisk.deleteDiskCacheFiles\"",
",",
"\"908\"",
",",
"cod",
")",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"cod",
".",
"cacheName",
"+",
"\"\\nException: \"",
"+",
"ExceptionUtility",
".",
"getStackTrace",
"(",
"t",
")",
")",
";",
"}",
"}",
"return",
"null",
";",
"}",
"}",
")",
";",
"}"
] | Call this method to delete all disk cache files per cache instance. | [
"Call",
"this",
"method",
"to",
"delete",
"all",
"disk",
"cache",
"files",
"per",
"cache",
"instance",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L937-L957 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java | CacheOnDisk.readAndDeleteInvalidationFile | protected ValueSet readAndDeleteInvalidationFile() {
final String methodName = "readAndDeleteInvalidationFile()";
final File f = new File(invalidationFileName);
final CacheOnDisk cod = this;
this.valueSet = new ValueSet(1);
if (f.exists()) {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
FileInputStream fis = null;
ObjectInputStream ois = null;
try {
fis = new FileInputStream(f);
ois = new ObjectInputStream(fis);
int size = ois.readInt();
cod.valueSet = new ValueSet(size);
for (int i = 0; i < size; i++) {
cod.valueSet.add(ois.readObject());
}
} catch (Throwable t1) {
com.ibm.ws.ffdc.FFDCFilter.processException(t1, "com.ibm.ws.cache.CacheOnDisk.readAndDeleteInvalidationFile", "1056", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t1));
} finally {
try {
if (ois != null) {
ois.close();
}
if (fis != null) {
fis.close();
}
f.delete();
} catch (Throwable t2) {
com.ibm.ws.ffdc.FFDCFilter
.processException(t2, "com.ibm.ws.cache.CacheOnDisk.readAndDeleteInvalidationFile", "1068", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t2));
}
}
return null;
}
});
}
traceDebug(methodName, "cacheName=" + this.cacheName + " " + invalidationFileName + " valueSet=" + valueSet.size());
return this.valueSet;
} | java | protected ValueSet readAndDeleteInvalidationFile() {
final String methodName = "readAndDeleteInvalidationFile()";
final File f = new File(invalidationFileName);
final CacheOnDisk cod = this;
this.valueSet = new ValueSet(1);
if (f.exists()) {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
FileInputStream fis = null;
ObjectInputStream ois = null;
try {
fis = new FileInputStream(f);
ois = new ObjectInputStream(fis);
int size = ois.readInt();
cod.valueSet = new ValueSet(size);
for (int i = 0; i < size; i++) {
cod.valueSet.add(ois.readObject());
}
} catch (Throwable t1) {
com.ibm.ws.ffdc.FFDCFilter.processException(t1, "com.ibm.ws.cache.CacheOnDisk.readAndDeleteInvalidationFile", "1056", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t1));
} finally {
try {
if (ois != null) {
ois.close();
}
if (fis != null) {
fis.close();
}
f.delete();
} catch (Throwable t2) {
com.ibm.ws.ffdc.FFDCFilter
.processException(t2, "com.ibm.ws.cache.CacheOnDisk.readAndDeleteInvalidationFile", "1068", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t2));
}
}
return null;
}
});
}
traceDebug(methodName, "cacheName=" + this.cacheName + " " + invalidationFileName + " valueSet=" + valueSet.size());
return this.valueSet;
} | [
"protected",
"ValueSet",
"readAndDeleteInvalidationFile",
"(",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"readAndDeleteInvalidationFile()\"",
";",
"final",
"File",
"f",
"=",
"new",
"File",
"(",
"invalidationFileName",
")",
";",
"final",
"CacheOnDisk",
"cod",
"=",
"this",
";",
"this",
".",
"valueSet",
"=",
"new",
"ValueSet",
"(",
"1",
")",
";",
"if",
"(",
"f",
".",
"exists",
"(",
")",
")",
"{",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedAction",
"(",
")",
"{",
"public",
"Object",
"run",
"(",
")",
"{",
"FileInputStream",
"fis",
"=",
"null",
";",
"ObjectInputStream",
"ois",
"=",
"null",
";",
"try",
"{",
"fis",
"=",
"new",
"FileInputStream",
"(",
"f",
")",
";",
"ois",
"=",
"new",
"ObjectInputStream",
"(",
"fis",
")",
";",
"int",
"size",
"=",
"ois",
".",
"readInt",
"(",
")",
";",
"cod",
".",
"valueSet",
"=",
"new",
"ValueSet",
"(",
"size",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"cod",
".",
"valueSet",
".",
"add",
"(",
"ois",
".",
"readObject",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t1",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"t1",
",",
"\"com.ibm.ws.cache.CacheOnDisk.readAndDeleteInvalidationFile\"",
",",
"\"1056\"",
",",
"cod",
")",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"cod",
".",
"cacheName",
"+",
"\"\\nException: \"",
"+",
"ExceptionUtility",
".",
"getStackTrace",
"(",
"t1",
")",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"ois",
"!=",
"null",
")",
"{",
"ois",
".",
"close",
"(",
")",
";",
"}",
"if",
"(",
"fis",
"!=",
"null",
")",
"{",
"fis",
".",
"close",
"(",
")",
";",
"}",
"f",
".",
"delete",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t2",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"t2",
",",
"\"com.ibm.ws.cache.CacheOnDisk.readAndDeleteInvalidationFile\"",
",",
"\"1068\"",
",",
"cod",
")",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"cod",
".",
"cacheName",
"+",
"\"\\nException: \"",
"+",
"ExceptionUtility",
".",
"getStackTrace",
"(",
"t2",
")",
")",
";",
"}",
"}",
"return",
"null",
";",
"}",
"}",
")",
";",
"}",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"this",
".",
"cacheName",
"+",
"\" \"",
"+",
"invalidationFileName",
"+",
"\" valueSet=\"",
"+",
"valueSet",
".",
"size",
"(",
")",
")",
";",
"return",
"this",
".",
"valueSet",
";",
"}"
] | Call this method to read in all invalidation cache ids if the invalidation file exists. and then delete the
invalidation file. | [
"Call",
"this",
"method",
"to",
"read",
"in",
"all",
"invalidation",
"cache",
"ids",
"if",
"the",
"invalidation",
"file",
"exists",
".",
"and",
"then",
"delete",
"the",
"invalidation",
"file",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L1076-L1118 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java | CacheOnDisk.createInvalidationFile | protected void createInvalidationFile() {
final String methodName = "createInvalidationFile()";
final File f = new File(invalidationFileName);
final CacheOnDisk cod = this;
traceDebug(methodName, "cacheName=" + this.cacheName + " valueSet=" + cod.valueSet.size());
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try {
fos = new FileOutputStream(f);
oos = new ObjectOutputStream(fos);
oos.writeInt(cod.valueSet.size());
Iterator it = valueSet.iterator();
while (it.hasNext()) {
Object entryId = it.next();
oos.writeObject(entryId);
}
} catch (Throwable t1) {
com.ibm.ws.ffdc.FFDCFilter.processException(t1, "com.ibm.ws.cache.CacheOnDisk.createInvalidationFile", "1106", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t1));
} finally {
try {
oos.close();
fos.close();
} catch (Throwable t2) {
com.ibm.ws.ffdc.FFDCFilter.processException(t2, "com.ibm.ws.cache.CacheOnDisk.createInvalidationFile", "1113", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t2));
}
}
return null;
}
});
} | java | protected void createInvalidationFile() {
final String methodName = "createInvalidationFile()";
final File f = new File(invalidationFileName);
final CacheOnDisk cod = this;
traceDebug(methodName, "cacheName=" + this.cacheName + " valueSet=" + cod.valueSet.size());
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try {
fos = new FileOutputStream(f);
oos = new ObjectOutputStream(fos);
oos.writeInt(cod.valueSet.size());
Iterator it = valueSet.iterator();
while (it.hasNext()) {
Object entryId = it.next();
oos.writeObject(entryId);
}
} catch (Throwable t1) {
com.ibm.ws.ffdc.FFDCFilter.processException(t1, "com.ibm.ws.cache.CacheOnDisk.createInvalidationFile", "1106", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t1));
} finally {
try {
oos.close();
fos.close();
} catch (Throwable t2) {
com.ibm.ws.ffdc.FFDCFilter.processException(t2, "com.ibm.ws.cache.CacheOnDisk.createInvalidationFile", "1113", cod);
traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t2));
}
}
return null;
}
});
} | [
"protected",
"void",
"createInvalidationFile",
"(",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"createInvalidationFile()\"",
";",
"final",
"File",
"f",
"=",
"new",
"File",
"(",
"invalidationFileName",
")",
";",
"final",
"CacheOnDisk",
"cod",
"=",
"this",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"this",
".",
"cacheName",
"+",
"\" valueSet=\"",
"+",
"cod",
".",
"valueSet",
".",
"size",
"(",
")",
")",
";",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedAction",
"(",
")",
"{",
"public",
"Object",
"run",
"(",
")",
"{",
"FileOutputStream",
"fos",
"=",
"null",
";",
"ObjectOutputStream",
"oos",
"=",
"null",
";",
"try",
"{",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"f",
")",
";",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"fos",
")",
";",
"oos",
".",
"writeInt",
"(",
"cod",
".",
"valueSet",
".",
"size",
"(",
")",
")",
";",
"Iterator",
"it",
"=",
"valueSet",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Object",
"entryId",
"=",
"it",
".",
"next",
"(",
")",
";",
"oos",
".",
"writeObject",
"(",
"entryId",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t1",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"t1",
",",
"\"com.ibm.ws.cache.CacheOnDisk.createInvalidationFile\"",
",",
"\"1106\"",
",",
"cod",
")",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"cod",
".",
"cacheName",
"+",
"\"\\nException: \"",
"+",
"ExceptionUtility",
".",
"getStackTrace",
"(",
"t1",
")",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"oos",
".",
"close",
"(",
")",
";",
"fos",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t2",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"t2",
",",
"\"com.ibm.ws.cache.CacheOnDisk.createInvalidationFile\"",
",",
"\"1113\"",
",",
"cod",
")",
";",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"cod",
".",
"cacheName",
"+",
"\"\\nException: \"",
"+",
"ExceptionUtility",
".",
"getStackTrace",
"(",
"t2",
")",
")",
";",
"}",
"}",
"return",
"null",
";",
"}",
"}",
")",
";",
"}"
] | Call this method to create invalidation file to offload the invalidation cache ids. When the server is restarted,
the invalidation cache ids are read back. The LPBT will be called to remove these cache ids from the disk. | [
"Call",
"this",
"method",
"to",
"create",
"invalidation",
"file",
"to",
"offload",
"the",
"invalidation",
"cache",
"ids",
".",
"When",
"the",
"server",
"is",
"restarted",
"the",
"invalidation",
"cache",
"ids",
"are",
"read",
"back",
".",
"The",
"LPBT",
"will",
"be",
"called",
"to",
"remove",
"these",
"cache",
"ids",
"from",
"the",
"disk",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L1124-L1159 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java | CacheOnDisk.alarm | public void alarm(final Object alarmContext) {
final String methodName = "alarm()";
synchronized (this) {
if (!stopping && !this.htod.invalidationBuffer.isDiskClearInProgress()) {
this.htod.invalidationBuffer.invokeBackgroundInvalidation(HTODInvalidationBuffer.SCAN);
} else if (stopping) {
traceDebug(methodName, "cacheName=" + this.cacheName + " abort disk cleanup because of server is stopping.");
} else {
if (cleanupFrequency == 0) {
sleepTime = calculateSleepTime();
}
traceDebug(methodName, "cacheName=" + this.cacheName + " disk clear is in progress - skip disk scan and set alarm sleepTime="
+ sleepTime);
Scheduler.createNonDeferrable(sleepTime, alarmContext, new Runnable() {
@Override
public void run() {
alarm(alarmContext);
}
});
}
}
} | java | public void alarm(final Object alarmContext) {
final String methodName = "alarm()";
synchronized (this) {
if (!stopping && !this.htod.invalidationBuffer.isDiskClearInProgress()) {
this.htod.invalidationBuffer.invokeBackgroundInvalidation(HTODInvalidationBuffer.SCAN);
} else if (stopping) {
traceDebug(methodName, "cacheName=" + this.cacheName + " abort disk cleanup because of server is stopping.");
} else {
if (cleanupFrequency == 0) {
sleepTime = calculateSleepTime();
}
traceDebug(methodName, "cacheName=" + this.cacheName + " disk clear is in progress - skip disk scan and set alarm sleepTime="
+ sleepTime);
Scheduler.createNonDeferrable(sleepTime, alarmContext, new Runnable() {
@Override
public void run() {
alarm(alarmContext);
}
});
}
}
} | [
"public",
"void",
"alarm",
"(",
"final",
"Object",
"alarmContext",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"alarm()\"",
";",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"!",
"stopping",
"&&",
"!",
"this",
".",
"htod",
".",
"invalidationBuffer",
".",
"isDiskClearInProgress",
"(",
")",
")",
"{",
"this",
".",
"htod",
".",
"invalidationBuffer",
".",
"invokeBackgroundInvalidation",
"(",
"HTODInvalidationBuffer",
".",
"SCAN",
")",
";",
"}",
"else",
"if",
"(",
"stopping",
")",
"{",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"this",
".",
"cacheName",
"+",
"\" abort disk cleanup because of server is stopping.\"",
")",
";",
"}",
"else",
"{",
"if",
"(",
"cleanupFrequency",
"==",
"0",
")",
"{",
"sleepTime",
"=",
"calculateSleepTime",
"(",
")",
";",
"}",
"traceDebug",
"(",
"methodName",
",",
"\"cacheName=\"",
"+",
"this",
".",
"cacheName",
"+",
"\" disk clear is in progress - skip disk scan and set alarm sleepTime=\"",
"+",
"sleepTime",
")",
";",
"Scheduler",
".",
"createNonDeferrable",
"(",
"sleepTime",
",",
"alarmContext",
",",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"alarm",
"(",
"alarmContext",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
"}"
] | Call this method when the alarm is triggered. It is being checked to see whether a disk cleanup is scheduled to
run. | [
"Call",
"this",
"method",
"when",
"the",
"alarm",
"is",
"triggered",
".",
"It",
"is",
"being",
"checked",
"to",
"see",
"whether",
"a",
"disk",
"cleanup",
"is",
"scheduled",
"to",
"run",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L1165-L1186 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java | CacheOnDisk.clearDiskCache | public void clearDiskCache() {
if (htod.clearDiskCache() == HTODDynacache.DISK_EXCEPTION) {
stopOnError(this.htod.diskCacheException);
} else {
updateLastScanFile();
updatePropertyFile();
createInProgressFile();
}
} | java | public void clearDiskCache() {
if (htod.clearDiskCache() == HTODDynacache.DISK_EXCEPTION) {
stopOnError(this.htod.diskCacheException);
} else {
updateLastScanFile();
updatePropertyFile();
createInProgressFile();
}
} | [
"public",
"void",
"clearDiskCache",
"(",
")",
"{",
"if",
"(",
"htod",
".",
"clearDiskCache",
"(",
")",
"==",
"HTODDynacache",
".",
"DISK_EXCEPTION",
")",
"{",
"stopOnError",
"(",
"this",
".",
"htod",
".",
"diskCacheException",
")",
";",
"}",
"else",
"{",
"updateLastScanFile",
"(",
")",
";",
"updatePropertyFile",
"(",
")",
";",
"createInProgressFile",
"(",
")",
";",
"}",
"}"
] | Call this method to clear the disk cache per cache instance. | [
"Call",
"this",
"method",
"to",
"clear",
"the",
"disk",
"cache",
"per",
"cache",
"instance",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L1222-L1230 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java | CacheOnDisk.writeCacheEntry | public int writeCacheEntry(CacheEntry ce) { // @A5C
int returnCode = htod.writeCacheEntry(ce);
if (returnCode == HTODDynacache.DISK_EXCEPTION) {
stopOnError(this.htod.diskCacheException);
}
return returnCode;
} | java | public int writeCacheEntry(CacheEntry ce) { // @A5C
int returnCode = htod.writeCacheEntry(ce);
if (returnCode == HTODDynacache.DISK_EXCEPTION) {
stopOnError(this.htod.diskCacheException);
}
return returnCode;
} | [
"public",
"int",
"writeCacheEntry",
"(",
"CacheEntry",
"ce",
")",
"{",
"// @A5C",
"int",
"returnCode",
"=",
"htod",
".",
"writeCacheEntry",
"(",
"ce",
")",
";",
"if",
"(",
"returnCode",
"==",
"HTODDynacache",
".",
"DISK_EXCEPTION",
")",
"{",
"stopOnError",
"(",
"this",
".",
"htod",
".",
"diskCacheException",
")",
";",
"}",
"return",
"returnCode",
";",
"}"
] | Call this method to write a cache entry to the disk. | [
"Call",
"this",
"method",
"to",
"write",
"a",
"cache",
"entry",
"to",
"the",
"disk",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L1235-L1241 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java | CacheOnDisk.readCacheEntry | public CacheEntry readCacheEntry(Object id) { // SKS-O
Result result = htod.readCacheEntry(id);
if (result.returnCode == HTODDynacache.DISK_EXCEPTION) {
stopOnError(result.diskException);
this.htod.returnToResultPool(result);
return null;
}
CacheEntry cacheEntry = (CacheEntry) result.data;
this.htod.returnToResultPool(result);
return cacheEntry;
} | java | public CacheEntry readCacheEntry(Object id) { // SKS-O
Result result = htod.readCacheEntry(id);
if (result.returnCode == HTODDynacache.DISK_EXCEPTION) {
stopOnError(result.diskException);
this.htod.returnToResultPool(result);
return null;
}
CacheEntry cacheEntry = (CacheEntry) result.data;
this.htod.returnToResultPool(result);
return cacheEntry;
} | [
"public",
"CacheEntry",
"readCacheEntry",
"(",
"Object",
"id",
")",
"{",
"// SKS-O",
"Result",
"result",
"=",
"htod",
".",
"readCacheEntry",
"(",
"id",
")",
";",
"if",
"(",
"result",
".",
"returnCode",
"==",
"HTODDynacache",
".",
"DISK_EXCEPTION",
")",
"{",
"stopOnError",
"(",
"result",
".",
"diskException",
")",
";",
"this",
".",
"htod",
".",
"returnToResultPool",
"(",
"result",
")",
";",
"return",
"null",
";",
"}",
"CacheEntry",
"cacheEntry",
"=",
"(",
"CacheEntry",
")",
"result",
".",
"data",
";",
"this",
".",
"htod",
".",
"returnToResultPool",
"(",
"result",
")",
";",
"return",
"cacheEntry",
";",
"}"
] | Call this method to read a cache entry from the disk.
@param id
- cache id. | [
"Call",
"this",
"method",
"to",
"read",
"a",
"cache",
"entry",
"from",
"the",
"disk",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L1249-L1259 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.