_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q6600 | AzureServiceClient.userAgent | train | public String userAgent() {
return String.format("Azure-SDK-For-Java/%s OS:%s MacAddressHash:%s Java:%s",
getClass().getPackage().getImplementationVersion(),
OS,
MAC_ADDRESS_HASH,
JAVA_VERSION);
} | java | {
"resource": ""
} |
q6601 | ResourceUtilsCore.groupFromResourceId | train | public static String groupFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).resourceGroupName() : null;
} | java | {
"resource": ""
} |
q6602 | ResourceUtilsCore.subscriptionFromResourceId | train | public static String subscriptionFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).subscriptionId() : null;
} | java | {
"resource": ""
} |
q6603 | ResourceUtilsCore.resourceProviderFromResourceId | train | public static String resourceProviderFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).providerNamespace() : null;
} | java | {
"resource": ""
} |
q6604 | ResourceUtilsCore.resourceTypeFromResourceId | train | public static String resourceTypeFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).resourceType() : null;
} | java | {
"resource": ""
} |
q6605 | ResourceUtilsCore.extractFromResourceId | train | public static String extractFromResourceId(String id, String identifier) {
if (id == null || identifier == null) {
return id;
}
Pattern pattern = Pattern.compile(identifier + "/[-\\w._]+");
Matcher matcher = pattern.matcher(id);
if (matcher.find()) {
return matcher.group().split("/")[1];
} else {
return null;
}
} | java | {
"resource": ""
} |
q6606 | ResourceUtilsCore.nameFromResourceId | train | public static String nameFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).name() : null;
} | java | {
"resource": ""
} |
q6607 | ResourceUtilsCore.constructResourceId | train | public static String constructResourceId(
final String subscriptionId,
final String resourceGroupName,
final String resourceProviderNamespace,
final String resourceType,
final String resourceName,
final String parentResourcePath) {
String prefixedParentPath = parentResourcePath;
if (parentResourcePath != null && !parentResourcePath.isEmpty()) {
prefixedParentPath = "/" + parentResourcePath;
}
return String.format(
"/subscriptions/%s/resourcegroups/%s/providers/%s%s/%s/%s",
subscriptionId,
resourceGroupName,
resourceProviderNamespace,
prefixedParentPath,
resourceType,
resourceName);
} | java | {
"resource": ""
} |
q6608 | AzureClient.getPutOrPatchResult | train | private <T> ServiceResponse<T> getPutOrPatchResult(Observable<Response<ResponseBody>> observable, Type resourceType) throws CloudException, InterruptedException, IOException {
Observable<ServiceResponse<T>> asyncObservable = getPutOrPatchResultAsync(observable, resourceType);
return asyncObservable.toBlocking().last();
} | java | {
"resource": ""
} |
q6609 | AzureClient.getPutOrPatchResultAsync | train | public <T> Observable<ServiceResponse<T>> getPutOrPatchResultAsync(Observable<Response<ResponseBody>> observable, final Type resourceType) {
return this.<T>beginPutOrPatchAsync(observable, resourceType)
.toObservable()
.flatMap(new Func1<PollingState<T>, Observable<PollingState<T>>>() {
@Override
public Observable<PollingState<T>> call(PollingState<T> pollingState) {
return pollPutOrPatchAsync(pollingState, resourceType);
}
})
.last()
.map(new Func1<PollingState<T>, ServiceResponse<T>>() {
@Override
public ServiceResponse<T> call(PollingState<T> pollingState) {
return new ServiceResponse<>(pollingState.resource(), pollingState.response());
}
});
} | java | {
"resource": ""
} |
q6610 | AzureClient.updateStateFromLocationHeaderOnPutAsync | train | private <T> Observable<PollingState<T>> updateStateFromLocationHeaderOnPutAsync(final PollingState<T> pollingState) {
return pollAsync(pollingState.locationHeaderLink(), pollingState.loggingContext())
.flatMap(new Func1<Response<ResponseBody>, Observable<PollingState<T>>>() {
@Override
public Observable<PollingState<T>> call(Response<ResponseBody> response) {
int statusCode = response.code();
if (statusCode == 202) {
pollingState.withResponse(response);
pollingState.withStatus(AzureAsyncOperation.IN_PROGRESS_STATUS, statusCode);
} else if (statusCode == 200 || statusCode == 201) {
try {
pollingState.updateFromResponseOnPutPatch(response);
} catch (CloudException | IOException e) {
return Observable.error(e);
}
}
return Observable.just(pollingState);
}
});
} | java | {
"resource": ""
} |
q6611 | AzureClient.updateStateFromGetResourceOperationAsync | train | private <T> Observable<PollingState<T>> updateStateFromGetResourceOperationAsync(final PollingState<T> pollingState, String url) {
return pollAsync(url, pollingState.loggingContext())
.flatMap(new Func1<Response<ResponseBody>, Observable<PollingState<T>>>() {
@Override
public Observable<PollingState<T>> call(Response<ResponseBody> response) {
try {
pollingState.updateFromResponseOnPutPatch(response);
return Observable.just(pollingState);
} catch (CloudException | IOException e) {
return Observable.error(e);
}
}
});
} | java | {
"resource": ""
} |
q6612 | AzureClient.pollAsync | train | private Observable<Response<ResponseBody>> pollAsync(String url, String loggingContext) {
URL endpoint;
try {
endpoint = new URL(url);
} catch (MalformedURLException e) {
return Observable.error(e);
}
AsyncService service = restClient().retrofit().create(AsyncService.class);
if (loggingContext != null && !loggingContext.endsWith(" (poll)")) {
loggingContext += " (poll)";
}
return service.get(endpoint.getFile(), serviceClientUserAgent, loggingContext)
.flatMap(new Func1<Response<ResponseBody>, Observable<Response<ResponseBody>>>() {
@Override
public Observable<Response<ResponseBody>> call(Response<ResponseBody> response) {
RuntimeException exception = createExceptionFromResponse(response, 200, 201, 202, 204);
if (exception != null) {
return Observable.error(exception);
} else {
return Observable.just(response);
}
}
});
} | java | {
"resource": ""
} |
q6613 | TaskGroup.taskResult | train | public Indexable taskResult(String taskId) {
TaskGroupEntry<TaskItem> taskGroupEntry = super.getNode(taskId);
if (taskGroupEntry != null) {
return taskGroupEntry.taskResult();
}
if (!this.proxyTaskGroupWrapper.isActive()) {
throw new IllegalArgumentException("A dependency task with id '" + taskId + "' is not found");
}
taskGroupEntry = this.proxyTaskGroupWrapper.proxyTaskGroup.getNode(taskId);
if (taskGroupEntry != null) {
return taskGroupEntry.taskResult();
}
throw new IllegalArgumentException("A dependency task or 'post-run' dependent task with with id '" + taskId + "' not found");
} | java | {
"resource": ""
} |
q6614 | TaskGroup.addDependency | train | public String addDependency(FunctionalTaskItem dependencyTaskItem) {
IndexableTaskItem dependency = IndexableTaskItem.create(dependencyTaskItem);
this.addDependency(dependency);
return dependency.key();
} | java | {
"resource": ""
} |
q6615 | TaskGroup.addDependencyTaskGroup | train | public void addDependencyTaskGroup(TaskGroup dependencyTaskGroup) {
if (dependencyTaskGroup.proxyTaskGroupWrapper.isActive()) {
dependencyTaskGroup.proxyTaskGroupWrapper.addDependentTaskGroup(this);
} else {
DAGraph<TaskItem, TaskGroupEntry<TaskItem>> dependencyGraph = dependencyTaskGroup;
super.addDependencyGraph(dependencyGraph);
}
} | java | {
"resource": ""
} |
q6616 | TaskGroup.addPostRunDependent | train | public String addPostRunDependent(FunctionalTaskItem dependentTaskItem) {
IndexableTaskItem taskItem = IndexableTaskItem.create(dependentTaskItem);
this.addPostRunDependent(taskItem);
return taskItem.key();
} | java | {
"resource": ""
} |
q6617 | TaskGroup.invokeReadyTasksAsync | train | private Observable<Indexable> invokeReadyTasksAsync(final InvocationContext context) {
TaskGroupEntry<TaskItem> readyTaskEntry = super.getNext();
final List<Observable<Indexable>> observables = new ArrayList<>();
// Enumerate the ready tasks (those with dependencies resolved) and kickoff them concurrently
//
while (readyTaskEntry != null) {
final TaskGroupEntry<TaskItem> currentEntry = readyTaskEntry;
final TaskItem currentTaskItem = currentEntry.data();
if (currentTaskItem instanceof ProxyTaskItem) {
observables.add(invokeAfterPostRunAsync(currentEntry, context));
} else {
observables.add(invokeTaskAsync(currentEntry, context));
}
readyTaskEntry = super.getNext();
}
return Observable.mergeDelayError(observables);
} | java | {
"resource": ""
} |
q6618 | TaskGroup.processFaultedTaskAsync | train | private Observable<Indexable> processFaultedTaskAsync(final TaskGroupEntry<TaskItem> faultedEntry,
final Throwable throwable,
final InvocationContext context) {
markGroupAsCancelledIfTerminationStrategyIsIPTC();
reportError(faultedEntry, throwable);
if (isRootEntry(faultedEntry)) {
if (shouldPropagateException(throwable)) {
return toErrorObservable(throwable);
}
return Observable.empty();
} else if (shouldPropagateException(throwable)) {
return Observable.concatDelayError(invokeReadyTasksAsync(context), toErrorObservable(throwable));
} else {
return invokeReadyTasksAsync(context);
}
} | java | {
"resource": ""
} |
q6619 | ExponentialBackoffRetryStrategy.shouldRetry | train | @Override
public boolean shouldRetry(int retryCount, Response response) {
int code = response.code();
//CHECKSTYLE IGNORE MagicNumber FOR NEXT 2 LINES
return retryCount < this.retryCount
&& (code == 408 || (code >= 500 && code != 501 && code != 505));
} | java | {
"resource": ""
} |
q6620 | RestClient.close | train | @Beta(SinceVersion.V1_1_0)
public void close() {
httpClient.dispatcher().executorService().shutdown();
httpClient.connectionPool().evictAll();
synchronized (httpClient.connectionPool()) {
httpClient.connectionPool().notifyAll();
}
synchronized (AsyncTimeout.class) {
AsyncTimeout.class.notifyAll();
}
} | java | {
"resource": ""
} |
q6621 | ReadableWrappersImpl.convertToPagedList | train | public static <InnerT> PagedList<InnerT> convertToPagedList(List<InnerT> list) {
PageImpl<InnerT> page = new PageImpl<>();
page.setItems(list);
page.setNextPageLink(null);
return new PagedList<InnerT>(page) {
@Override
public Page<InnerT> nextPage(String nextPageLink) {
return null;
}
};
} | java | {
"resource": ""
} |
q6622 | ReadableWrappersImpl.convertListToInnerAsync | train | public static <InnerT> Observable<InnerT> convertListToInnerAsync(Observable<List<InnerT>> innerList) {
return innerList.flatMap(new Func1<List<InnerT>, Observable<InnerT>>() {
@Override
public Observable<InnerT> call(List<InnerT> inners) {
return Observable.from(inners);
}
});
} | java | {
"resource": ""
} |
q6623 | ReadableWrappersImpl.convertPageToInnerAsync | train | public static <InnerT> Observable<InnerT> convertPageToInnerAsync(Observable<Page<InnerT>> innerPage) {
return innerPage.flatMap(new Func1<Page<InnerT>, Observable<InnerT>>() {
@Override
public Observable<InnerT> call(Page<InnerT> pageInner) {
return Observable.from(pageInner.items());
}
});
} | java | {
"resource": ""
} |
q6624 | PostRunTaskCollection.add | train | public void add(final IndexableTaskItem taskItem) {
this.dependsOnTaskGroup.addPostRunDependentTaskGroup(taskItem.taskGroup());
this.collection.add(taskItem);
} | java | {
"resource": ""
} |
q6625 | S3ObjectWriter.putAsync | train | public Eval<UploadResult> putAsync(String key, Object value) {
return Eval.later(() -> put(key, value))
.map(t -> t.orElse(null))
.map(FluentFunctions.ofChecked(up -> up.waitForUploadResult()));
} | java | {
"resource": ""
} |
q6626 | S3StringWriter.putAsync | train | public Future<PutObjectResult> putAsync(String key, String value) {
return Future.of(() -> put(key, value), this.uploadService)
.flatMap(t->t.fold(p->Future.ofResult(p),e->Future.ofError(e)));
} | java | {
"resource": ""
} |
q6627 | LabelledEvents.finish | train | public static <T> void finish(T query, long correlationId, EventBus bus, String... labels) {
for (String type : labels) {
RemoveLabelledQuery<T> next = finish(query, correlationId, type);
bus.post(next);
}
} | java | {
"resource": ""
} |
q6628 | RequestEvents.start | train | public static <T> AddQuery<T> start(T query, long correlationId) {
return start(query, correlationId, "default", null);
} | java | {
"resource": ""
} |
q6629 | RequestEvents.finish | train | public static <T> void finish(T query, long correlationId, EventBus bus, String... types) {
for (String type : types) {
RemoveQuery<T> next = finish(query, correlationId, type);
bus.post(next);
}
} | java | {
"resource": ""
} |
q6630 | TransactionFlow.execute | train | public Try<R,Throwable> execute(T input){
return Try.withCatch( ()->transactionTemplate.execute(status-> transaction.apply(input)));
} | java | {
"resource": ""
} |
q6631 | TransactionFlow.execute | train | public <Ex extends Throwable> Try<R,Ex> execute(T input,Class<Ex> classes){
return Try.withCatch( ()->transactionTemplate.execute(status-> transaction.apply(input)),classes);
} | java | {
"resource": ""
} |
q6632 | DataTablesInput.getColumn | train | public Column getColumn(String columnName) {
if (columnName == null) {
return null;
}
for (Column column : columns) {
if (columnName.equals(column.getData())) {
return column;
}
}
return null;
} | java | {
"resource": ""
} |
q6633 | DataTablesInput.addColumn | train | public void addColumn(String columnName, boolean searchable, boolean orderable,
String searchValue) {
this.columns.add(new Column(columnName, "", searchable, orderable,
new Search(searchValue, false)));
} | java | {
"resource": ""
} |
q6634 | DataTablesInput.addOrder | train | public void addOrder(String columnName, boolean ascending) {
if (columnName == null) {
return;
}
for (int i = 0; i < columns.size(); i++) {
if (!columnName.equals(columns.get(i).getData())) {
continue;
}
order.add(new Order(i, ascending ? "asc" : "desc"));
}
} | java | {
"resource": ""
} |
q6635 | CiModelInterpolator.interpolateModel | train | public Model interpolateModel(Model model, File projectDir, ModelBuildingRequest config,
ModelProblemCollector problems) {
interpolateObject(model, model, projectDir, config, problems);
return model;
} | java | {
"resource": ""
} |
q6636 | CiInterpolatorImpl.interpolate | train | public String interpolate( String input, RecursionInterceptor recursionInterceptor )
throws InterpolationException
{
try
{
return interpolate( input, recursionInterceptor, new HashSet<String>() );
}
finally
{
if ( !cacheAnswers )
{
existingAnswers.clear();
}
}
} | java | {
"resource": ""
} |
q6637 | CiInterpolatorImpl.getFeedback | train | public List getFeedback()
{
List<?> messages = new ArrayList();
for ( ValueSource vs : valueSources )
{
List feedback = vs.getFeedback();
if ( feedback != null && !feedback.isEmpty() )
{
messages.addAll( feedback );
}
}
return messages;
} | java | {
"resource": ""
} |
q6638 | FlattenModelResolver.resolveModel | train | public ModelSource resolveModel( Parent parent )
throws UnresolvableModelException {
Dependency parentDependency = new Dependency();
parentDependency.setGroupId(parent.getGroupId());
parentDependency.setArtifactId(parent.getArtifactId());
parentDependency.setVersion(parent.getVersion());
parentDependency.setClassifier("");
parentDependency.setType("pom");
Artifact parentArtifact = null;
try
{
Iterable<ArtifactResult> artifactResults = depencencyResolver.resolveDependencies(
projectBuildingRequest, singleton(parentDependency), null, null );
Iterator<ArtifactResult> iterator = artifactResults.iterator();
if (iterator.hasNext()) {
parentArtifact = iterator.next().getArtifact();
}
} catch (DependencyResolverException e) {
throw new UnresolvableModelException( e.getMessage(), parent.getGroupId(), parent.getArtifactId(),
parent.getVersion(), e );
}
return resolveModel( parentArtifact.getGroupId(), parentArtifact.getArtifactId(), parentArtifact.getVersion() );
} | java | {
"resource": ""
} |
q6639 | FlattenMojo.extractHeaderComment | train | protected String extractHeaderComment( File xmlFile )
throws MojoExecutionException
{
try
{
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
SaxHeaderCommentHandler handler = new SaxHeaderCommentHandler();
parser.setProperty( "http://xml.org/sax/properties/lexical-handler", handler );
parser.parse( xmlFile, handler );
return handler.getHeaderComment();
}
catch ( Exception e )
{
throw new MojoExecutionException( "Failed to parse XML from " + xmlFile, e );
}
} | java | {
"resource": ""
} |
q6640 | FlattenMojo.createFlattenedPom | train | protected Model createFlattenedPom( File pomFile )
throws MojoExecutionException, MojoFailureException
{
ModelBuildingRequest buildingRequest = createModelBuildingRequest( pomFile );
Model effectivePom = createEffectivePom( buildingRequest, isEmbedBuildProfileDependencies(), this.flattenMode );
Model flattenedPom = new Model();
// keep original encoding (we could also normalize to UTF-8 here)
String modelEncoding = effectivePom.getModelEncoding();
if ( StringUtils.isEmpty( modelEncoding ) )
{
modelEncoding = "UTF-8";
}
flattenedPom.setModelEncoding( modelEncoding );
Model cleanPom = createCleanPom( effectivePom );
FlattenDescriptor descriptor = getFlattenDescriptor();
Model originalPom = this.project.getOriginalModel();
Model resolvedPom = this.project.getModel();
Model interpolatedPom = createResolvedPom( buildingRequest );
// copy the configured additional POM elements...
for ( PomProperty<?> property : PomProperty.getPomProperties() )
{
if ( property.isElement() )
{
Model sourceModel = getSourceModel( descriptor, property, effectivePom, originalPom, resolvedPom,
interpolatedPom, cleanPom );
if ( sourceModel == null )
{
if ( property.isRequired() )
{
throw new MojoFailureException( "Property " + property.getName()
+ " is required and can not be removed!" );
}
}
else
{
property.copy( sourceModel, flattenedPom );
}
}
}
return flattenedPom;
} | java | {
"resource": ""
} |
q6641 | CharacterUtils.toCodePoints | train | public final int toCodePoints(char[] src, int srcOff, int srcLen, int[] dest, int destOff) {
if (srcLen < 0) {
throw new IllegalArgumentException("srcLen must be >= 0");
}
int codePointCount = 0;
for (int i = 0; i < srcLen; ) {
final int cp = codePointAt(src, srcOff + i, srcOff + srcLen);
final int charCount = Character.charCount(cp);
dest[destOff + codePointCount++] = cp;
i += charCount;
}
return codePointCount;
} | java | {
"resource": ""
} |
q6642 | CharacterUtils.toChars | train | public final int toChars(int[] src, int srcOff, int srcLen, char[] dest, int destOff) {
if (srcLen < 0) {
throw new IllegalArgumentException("srcLen must be >= 0");
}
int written = 0;
for (int i = 0; i < srcLen; ++i) {
written += Character.toChars(src[srcOff + i], dest, destOff + written);
}
return written;
} | java | {
"resource": ""
} |
q6643 | TwitterKoreanProcessorJava.splitSentences | train | public static List<Sentence> splitSentences(CharSequence text) {
return JavaConversions.seqAsJavaList(
TwitterKoreanProcessor.splitSentences(text)
);
} | java | {
"resource": ""
} |
q6644 | TwitterKoreanProcessorJava.extractPhrases | train | public static List<KoreanPhraseExtractor.KoreanPhrase> extractPhrases(Seq<KoreanToken> tokens, boolean filterSpam, boolean includeHashtags) {
return JavaConversions.seqAsJavaList(
TwitterKoreanProcessor.extractPhrases(tokens, filterSpam, includeHashtags)
);
} | java | {
"resource": ""
} |
q6645 | TwitterKoreanProcessorJava.detokenize | train | public static String detokenize(List<String> tokens) {
return TwitterKoreanProcessor.detokenize(JavaConversions.iterableAsScalaIterable(tokens));
} | java | {
"resource": ""
} |
q6646 | ConverterServerBuilder.baseUri | train | public ConverterServerBuilder baseUri(String baseUri) {
checkNotNull(baseUri);
this.baseUri = URI.create(baseUri);
return this;
} | java | {
"resource": ""
} |
q6647 | ConverterServerBuilder.workerPool | train | public ConverterServerBuilder workerPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit) {
assertNumericArgument(corePoolSize, true);
assertNumericArgument(maximumPoolSize, true);
assertNumericArgument(corePoolSize + maximumPoolSize, false);
assertNumericArgument(keepAliveTime, true);
this.corePoolSize = corePoolSize;
this.maximumPoolSize = maximumPoolSize;
this.keepAliveTime = unit.toMillis(keepAliveTime);
return this;
} | java | {
"resource": ""
} |
q6648 | ConverterServerBuilder.requestTimeout | train | public ConverterServerBuilder requestTimeout(long timeout, TimeUnit unit) {
assertNumericArgument(timeout, true);
this.requestTimeout = unit.toMillis(timeout);
return this;
} | java | {
"resource": ""
} |
q6649 | ConverterServerBuilder.processTimeout | train | public ConverterServerBuilder processTimeout(long processTimeout, TimeUnit timeUnit) {
assertNumericArgument(processTimeout, false);
this.processTimeout = timeUnit.toMillis(processTimeout);
return this;
} | java | {
"resource": ""
} |
q6650 | ConverterServerBuilder.build | train | public HttpServer build() {
checkNotNull(baseUri);
StandaloneWebConverterConfiguration configuration = makeConfiguration();
// The configuration has to be configured both by a binder to make it injectable
// and directly in order to trigger life cycle methods on the deployment container.
ResourceConfig resourceConfig = ResourceConfig
.forApplication(new WebConverterApplication(configuration))
.register(configuration);
if (sslContext == null) {
return GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig);
} else {
return GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig, true, new SSLEngineConfigurator(sslContext));
}
} | java | {
"resource": ""
} |
q6651 | ParentViewHolder.getParentAdapterPosition | train | @UiThread
public int getParentAdapterPosition() {
int flatPosition = getAdapterPosition();
if (flatPosition == RecyclerView.NO_POSITION) {
return flatPosition;
}
return mExpandableAdapter.getNearestParentPosition(flatPosition);
} | java | {
"resource": ""
} |
q6652 | ParentViewHolder.expandView | train | @UiThread
protected void expandView() {
setExpanded(true);
onExpansionToggled(false);
if (mParentViewHolderExpandCollapseListener != null) {
mParentViewHolderExpandCollapseListener.onParentExpanded(getAdapterPosition());
}
} | java | {
"resource": ""
} |
q6653 | ParentViewHolder.collapseView | train | @UiThread
protected void collapseView() {
setExpanded(false);
onExpansionToggled(true);
if (mParentViewHolderExpandCollapseListener != null) {
mParentViewHolderExpandCollapseListener.onParentCollapsed(getAdapterPosition());
}
} | java | {
"resource": ""
} |
q6654 | ExpandableRecyclerAdapter.parentExpandedFromViewHolder | train | @UiThread
protected void parentExpandedFromViewHolder(int flatParentPosition) {
ExpandableWrapper<P, C> parentWrapper = mFlatItemList.get(flatParentPosition);
updateExpandedParent(parentWrapper, flatParentPosition, true);
} | java | {
"resource": ""
} |
q6655 | ExpandableRecyclerAdapter.parentCollapsedFromViewHolder | train | @UiThread
protected void parentCollapsedFromViewHolder(int flatParentPosition) {
ExpandableWrapper<P, C> parentWrapper = mFlatItemList.get(flatParentPosition);
updateCollapsedParent(parentWrapper, flatParentPosition, true);
} | java | {
"resource": ""
} |
q6656 | ExpandableRecyclerAdapter.expandParentRange | train | @UiThread
public void expandParentRange(int startParentPosition, int parentCount) {
int endParentPosition = startParentPosition + parentCount;
for (int i = startParentPosition; i < endParentPosition; i++) {
expandParent(i);
}
} | java | {
"resource": ""
} |
q6657 | ExpandableRecyclerAdapter.collapseParentRange | train | @UiThread
public void collapseParentRange(int startParentPosition, int parentCount) {
int endParentPosition = startParentPosition + parentCount;
for (int i = startParentPosition; i < endParentPosition; i++) {
collapseParent(i);
}
} | java | {
"resource": ""
} |
q6658 | ExpandableRecyclerAdapter.generateFlattenedParentChildList | train | private List<ExpandableWrapper<P, C>> generateFlattenedParentChildList(List<P> parentList) {
List<ExpandableWrapper<P, C>> flatItemList = new ArrayList<>();
int parentCount = parentList.size();
for (int i = 0; i < parentCount; i++) {
P parent = parentList.get(i);
generateParentWrapper(flatItemList, parent, parent.isInitiallyExpanded());
}
return flatItemList;
} | java | {
"resource": ""
} |
q6659 | ExpandableRecyclerAdapter.generateFlattenedParentChildList | train | private List<ExpandableWrapper<P, C>> generateFlattenedParentChildList(List<P> parentList, Map<P, Boolean> savedLastExpansionState) {
List<ExpandableWrapper<P, C>> flatItemList = new ArrayList<>();
int parentCount = parentList.size();
for (int i = 0; i < parentCount; i++) {
P parent = parentList.get(i);
Boolean lastExpandedState = savedLastExpansionState.get(parent);
boolean shouldExpand = lastExpandedState == null ? parent.isInitiallyExpanded() : lastExpandedState;
generateParentWrapper(flatItemList, parent, shouldExpand);
}
return flatItemList;
} | java | {
"resource": ""
} |
q6660 | ExpandableRecyclerAdapter.generateExpandedStateMap | train | @NonNull
@UiThread
private HashMap<Integer, Boolean> generateExpandedStateMap() {
HashMap<Integer, Boolean> parentHashMap = new HashMap<>();
int childCount = 0;
int listItemCount = mFlatItemList.size();
for (int i = 0; i < listItemCount; i++) {
if (mFlatItemList.get(i) != null) {
ExpandableWrapper<P, C> listItem = mFlatItemList.get(i);
if (listItem.isParent()) {
parentHashMap.put(i - childCount, listItem.isExpanded());
} else {
childCount++;
}
}
}
return parentHashMap;
} | java | {
"resource": ""
} |
q6661 | ExpandableRecyclerAdapter.getFlatParentPosition | train | @UiThread
private int getFlatParentPosition(int parentPosition) {
int parentCount = 0;
int listItemCount = mFlatItemList.size();
for (int i = 0; i < listItemCount; i++) {
if (mFlatItemList.get(i).isParent()) {
parentCount++;
if (parentCount > parentPosition) {
return i;
}
}
}
return INVALID_FLAT_POSITION;
} | java | {
"resource": ""
} |
q6662 | ChildViewHolder.getParentAdapterPosition | train | @UiThread
public int getParentAdapterPosition() {
int flatPosition = getAdapterPosition();
if (mExpandableAdapter == null || flatPosition == RecyclerView.NO_POSITION) {
return RecyclerView.NO_POSITION;
}
return mExpandableAdapter.getNearestParentPosition(flatPosition);
} | java | {
"resource": ""
} |
q6663 | ChildViewHolder.getChildAdapterPosition | train | @UiThread
public int getChildAdapterPosition() {
int flatPosition = getAdapterPosition();
if (mExpandableAdapter == null || flatPosition == RecyclerView.NO_POSITION) {
return RecyclerView.NO_POSITION;
}
return mExpandableAdapter.getChildPosition(flatPosition);
} | java | {
"resource": ""
} |
q6664 | PoolUtil.fillLogParams | train | public static String fillLogParams(String sql, Map<Object, Object> logParams) {
StringBuilder result = new StringBuilder();
Map<Object, Object> tmpLogParam = (logParams == null ? new HashMap<Object, Object>() : logParams);
Iterator<Object> it = tmpLogParam.values().iterator();
boolean inQuote = false;
boolean inQuote2 = false;
char[] sqlChar = sql != null ? sql.toCharArray() : new char[]{};
for (int i=0; i < sqlChar.length; i++){
if (sqlChar[i] == '\''){
inQuote = !inQuote;
}
if (sqlChar[i] == '"'){
inQuote2 = !inQuote2;
}
if (sqlChar[i] == '?' && !(inQuote || inQuote2)){
if (it.hasNext()){
result.append(prettyPrint(it.next()));
} else {
result.append('?');
}
} else {
result.append(sqlChar[i]);
}
}
return result.toString();
} | java | {
"resource": ""
} |
q6665 | ConnectionHandle.sendInitSQL | train | protected static void sendInitSQL(Connection connection, String initSQL) throws SQLException{
// fetch any configured setup sql.
if (initSQL != null){
Statement stmt = null;
try{
stmt = connection.createStatement();
stmt.execute(initSQL);
if (testSupport){ // only to aid code coverage, normally set to false
stmt = null;
}
} finally{
if (stmt != null){
stmt.close();
}
}
}
} | java | {
"resource": ""
} |
q6666 | ConnectionHandle.close | train | public void close() throws SQLException {
try {
if (this.resetConnectionOnClose /*FIXME: && !getAutoCommit() && !isTxResolved() */){
/*if (this.autoCommitStackTrace != null){
logger.debug(this.autoCommitStackTrace);
this.autoCommitStackTrace = null;
} else {
logger.debug(DISABLED_AUTO_COMMIT_WARNING);
}*/
rollback();
if (!getAutoCommit()){
setAutoCommit(true);
}
}
if (this.logicallyClosed.compareAndSet(false, true)) {
if (this.threadWatch != null){
this.threadWatch.interrupt(); // if we returned the connection to the pool, terminate thread watch thread if it's
// running even if thread is still alive (eg thread has been recycled for use in some
// container).
this.threadWatch = null;
}
if (this.closeOpenStatements){
for (Entry<Statement, String> statementEntry: this.trackedStatement.entrySet()){
statementEntry.getKey().close();
if (this.detectUnclosedStatements){
logger.warn(String.format(UNCLOSED_LOG_ERROR_MESSAGE, statementEntry.getValue()));
}
}
this.trackedStatement.clear();
}
if (!this.connectionTrackingDisabled){
pool.getFinalizableRefs().remove(this.connection);
}
ConnectionHandle handle = null;
//recreate can throw a SQLException in constructor on recreation
try {
handle = this.recreateConnectionHandle();
this.pool.connectionStrategy.cleanupConnection(this, handle);
this.pool.releaseConnection(handle);
} catch(SQLException e) {
//check if the connection was already closed by the recreation
if (!isClosed()) {
this.pool.connectionStrategy.cleanupConnection(this, handle);
this.pool.releaseConnection(this);
}
throw e;
}
if (this.doubleCloseCheck){
this.doubleCloseException = this.pool.captureStackTrace(CLOSED_TWICE_EXCEPTION_MESSAGE);
}
} else {
if (this.doubleCloseCheck && this.doubleCloseException != null){
String currentLocation = this.pool.captureStackTrace("Last closed trace from thread ["+Thread.currentThread().getName()+"]:\n");
logger.error(String.format(LOG_ERROR_MESSAGE, this.doubleCloseException, currentLocation));
}
}
} catch (SQLException e) {
throw markPossiblyBroken(e);
}
} | java | {
"resource": ""
} |
q6667 | ConnectionHandle.internalClose | train | protected void internalClose() throws SQLException {
try {
clearStatementCaches(true);
if (this.connection != null){ // safety!
this.connection.close();
if (!this.connectionTrackingDisabled && this.finalizableRefs != null){
this.finalizableRefs.remove(this.connection);
}
}
this.logicallyClosed.set(true);
} catch (SQLException e) {
throw markPossiblyBroken(e);
}
} | java | {
"resource": ""
} |
q6668 | ConnectionHandle.clearStatementCaches | train | protected void clearStatementCaches(boolean internalClose) {
if (this.statementCachingEnabled){ // safety
if (internalClose){
this.callableStatementCache.clear();
this.preparedStatementCache.clear();
} else {
if (this.pool.closeConnectionWatch){ // debugging enabled?
this.callableStatementCache.checkForProperClosure();
this.preparedStatementCache.checkForProperClosure();
}
}
}
} | java | {
"resource": ""
} |
q6669 | ConnectionHandle.getProxyTarget | train | public Object getProxyTarget(){
try {
return Proxy.getInvocationHandler(this.connection).invoke(null, this.getClass().getMethod("getProxyTarget"), null);
} catch (Throwable t) {
throw new RuntimeException("BoneCP: Internal error - transaction replay log is not turned on?", t);
}
} | java | {
"resource": ""
} |
q6670 | ConnectionHandle.refreshConnection | train | public void refreshConnection() throws SQLException{
this.connection.close(); // if it's still in use, close it.
try{
this.connection = this.pool.obtainRawInternalConnection();
} catch(SQLException e){
throw markPossiblyBroken(e);
}
} | java | {
"resource": ""
} |
q6671 | DynamicDataSourceProxy.switchDataSource | train | public void switchDataSource(BoneCPConfig newConfig) throws SQLException {
logger.info("Switch to new datasource requested. New Config: "+newConfig);
DataSource oldDS = getTargetDataSource();
if (!(oldDS instanceof BoneCPDataSource)){
throw new SQLException("Unknown datasource type! Was expecting BoneCPDataSource but received "+oldDS.getClass()+". Not switching datasource!");
}
BoneCPDataSource newDS = new BoneCPDataSource(newConfig);
newDS.getConnection().close(); // initialize a connection (+ throw it away) to force the datasource to initialize the pool
// force application to start using the new one
setTargetDataSource(newDS);
logger.info("Shutting down old datasource slowly. Old Config: "+oldDS);
// tell the old datasource to terminate. This terminates the pool lazily so existing checked out connections can still be used.
((BoneCPDataSource)oldDS).close();
} | java | {
"resource": ""
} |
q6672 | MemorizeTransactionProxy.memorize | train | protected static Connection memorize(final Connection target, final ConnectionHandle connectionHandle) {
return (Connection) Proxy.newProxyInstance(
ConnectionProxy.class.getClassLoader(),
new Class[] {ConnectionProxy.class},
new MemorizeTransactionProxy(target, connectionHandle));
} | java | {
"resource": ""
} |
q6673 | MemorizeTransactionProxy.memorize | train | protected static Statement memorize(final Statement target, final ConnectionHandle connectionHandle) {
return (Statement) Proxy.newProxyInstance(
StatementProxy.class.getClassLoader(),
new Class[] {StatementProxy.class},
new MemorizeTransactionProxy(target, connectionHandle));
} | java | {
"resource": ""
} |
q6674 | MemorizeTransactionProxy.memorize | train | protected static PreparedStatement memorize(final PreparedStatement target, final ConnectionHandle connectionHandle) {
return (PreparedStatement) Proxy.newProxyInstance(
PreparedStatementProxy.class.getClassLoader(),
new Class[] {PreparedStatementProxy.class},
new MemorizeTransactionProxy(target, connectionHandle));
} | java | {
"resource": ""
} |
q6675 | MemorizeTransactionProxy.memorize | train | protected static CallableStatement memorize(final CallableStatement target, final ConnectionHandle connectionHandle) {
return (CallableStatement) Proxy.newProxyInstance(
CallableStatementProxy.class.getClassLoader(),
new Class[] {CallableStatementProxy.class},
new MemorizeTransactionProxy(target, connectionHandle));
} | java | {
"resource": ""
} |
q6676 | MemorizeTransactionProxy.runWithPossibleProxySwap | train | private Object runWithPossibleProxySwap(Method method, Object target, Object[] args)
throws IllegalAccessException, InvocationTargetException {
Object result;
// swap with proxies to these too.
if (method.getName().equals("createStatement")){
result = memorize((Statement)method.invoke(target, args), this.connectionHandle.get());
}
else if (method.getName().equals("prepareStatement")){
result = memorize((PreparedStatement)method.invoke(target, args), this.connectionHandle.get());
}
else if (method.getName().equals("prepareCall")){
result = memorize((CallableStatement)method.invoke(target, args), this.connectionHandle.get());
}
else result = method.invoke(target, args);
return result;
} | java | {
"resource": ""
} |
q6677 | PoolWatchThread.fillConnections | train | private void fillConnections(int connectionsToCreate) throws InterruptedException {
try {
for (int i=0; i < connectionsToCreate; i++){
// boolean dbDown = this.pool.getDbIsDown().get();
if (this.pool.poolShuttingDown){
break;
}
this.partition.addFreeConnection(new ConnectionHandle(null, this.partition, this.pool, false));
}
} catch (Exception e) {
logger.error("Error in trying to obtain a connection. Retrying in "+this.acquireRetryDelayInMs+"ms", e);
Thread.sleep(this.acquireRetryDelayInMs);
}
} | java | {
"resource": ""
} |
q6678 | StatementCache.calculateCacheKey | train | public String calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability){
StringBuilder tmp = calculateCacheKeyInternal(sql, resultSetType,
resultSetConcurrency);
tmp.append(", H:");
tmp.append(resultSetHoldability);
return tmp.toString();
} | java | {
"resource": ""
} |
q6679 | StatementCache.calculateCacheKeyInternal | train | private StringBuilder calculateCacheKeyInternal(String sql,
int resultSetType, int resultSetConcurrency) {
StringBuilder tmp = new StringBuilder(sql.length()+20);
tmp.append(sql);
tmp.append(", T");
tmp.append(resultSetType);
tmp.append(", C");
tmp.append(resultSetConcurrency);
return tmp;
} | java | {
"resource": ""
} |
q6680 | StatementCache.calculateCacheKey | train | public String calculateCacheKey(String sql, int autoGeneratedKeys) {
StringBuilder tmp = new StringBuilder(sql.length()+4);
tmp.append(sql);
tmp.append(autoGeneratedKeys);
return tmp.toString();
} | java | {
"resource": ""
} |
q6681 | StatementCache.calculateCacheKey | train | public String calculateCacheKey(String sql, int[] columnIndexes) {
StringBuilder tmp = new StringBuilder(sql.length()+4);
tmp.append(sql);
for (int i=0; i < columnIndexes.length; i++){
tmp.append(columnIndexes[i]);
tmp.append("CI,");
}
return tmp.toString();
} | java | {
"resource": ""
} |
q6682 | ConnectionMaxAgeThread.run | train | public void run() {
ConnectionHandle connection = null;
long tmp;
long nextCheckInMs = this.maxAgeInMs;
int partitionSize= this.partition.getAvailableConnections();
long currentTime = System.currentTimeMillis();
for (int i=0; i < partitionSize; i++){
try {
connection = this.partition.getFreeConnections().poll();
if (connection != null){
connection.setOriginatingPartition(this.partition);
tmp = this.maxAgeInMs - (currentTime - connection.getConnectionCreationTimeInMs());
if (tmp < nextCheckInMs){
nextCheckInMs = tmp;
}
if (connection.isExpired(currentTime)){
// kill off this connection
closeConnection(connection);
continue;
}
if (this.lifoMode){
// we can't put it back normally or it will end up in front again.
if (!(connection.getOriginatingPartition().getFreeConnections().offer(connection))){
connection.internalClose();
}
} else {
this.pool.putConnectionBackInPartition(connection);
}
Thread.sleep(20L); // test slowly, this is not an operation that we're in a hurry to deal with (avoid CPU spikes)...
}
} catch (Throwable e) {
logger.error("Connection max age thread exception.", e);
}
} // throw it back on the queue
} | java | {
"resource": ""
} |
q6683 | ConnectionMaxAgeThread.closeConnection | train | protected void closeConnection(ConnectionHandle connection) {
if (connection != null) {
try {
connection.internalClose();
} catch (Throwable t) {
logger.error("Destroy connection exception", t);
} finally {
this.pool.postDestroyConnection(connection);
}
}
} | java | {
"resource": ""
} |
q6684 | BoneCPConfig.setIdleMaxAge | train | public void setIdleMaxAge(long idleMaxAge, TimeUnit timeUnit) {
this.idleMaxAgeInSeconds = TimeUnit.SECONDS.convert(idleMaxAge, checkNotNull(timeUnit));
} | java | {
"resource": ""
} |
q6685 | BoneCPConfig.setAcquireRetryDelay | train | public void setAcquireRetryDelay(long acquireRetryDelay, TimeUnit timeUnit) {
this.acquireRetryDelayInMs = TimeUnit.MILLISECONDS.convert(acquireRetryDelay, timeUnit);
} | java | {
"resource": ""
} |
q6686 | BoneCPConfig.setQueryExecuteTimeLimit | train | public void setQueryExecuteTimeLimit(long queryExecuteTimeLimit, TimeUnit timeUnit) {
this.queryExecuteTimeLimitInMs = TimeUnit.MILLISECONDS.convert(queryExecuteTimeLimit, timeUnit);
} | java | {
"resource": ""
} |
q6687 | BoneCPConfig.setConnectionTimeout | train | public void setConnectionTimeout(long connectionTimeout, TimeUnit timeUnit) {
this.connectionTimeoutInMs = TimeUnit.MILLISECONDS.convert(connectionTimeout, timeUnit);
} | java | {
"resource": ""
} |
q6688 | BoneCPConfig.setCloseConnectionWatchTimeout | train | public void setCloseConnectionWatchTimeout(long closeConnectionWatchTimeout, TimeUnit timeUnit) {
this.closeConnectionWatchTimeoutInMs = TimeUnit.MILLISECONDS.convert(closeConnectionWatchTimeout, timeUnit);
} | java | {
"resource": ""
} |
q6689 | BoneCPConfig.setMaxConnectionAge | train | public void setMaxConnectionAge(long maxConnectionAge, TimeUnit timeUnit) {
this.maxConnectionAgeInSeconds = TimeUnit.SECONDS.convert(maxConnectionAge, timeUnit);
} | java | {
"resource": ""
} |
q6690 | BoneCPConfig.parseXML | train | private Properties parseXML(Document doc, String sectionName) {
int found = -1;
Properties results = new Properties();
NodeList config = null;
if (sectionName == null){
config = doc.getElementsByTagName("default-config");
found = 0;
} else {
config = doc.getElementsByTagName("named-config");
if(config != null && config.getLength() > 0) {
for (int i = 0; i < config.getLength(); i++) {
Node node = config.item(i);
if(node.getNodeType() == Node.ELEMENT_NODE ){
NamedNodeMap attributes = node.getAttributes();
if (attributes != null && attributes.getLength() > 0){
Node name = attributes.getNamedItem("name");
if (name.getNodeValue().equalsIgnoreCase(sectionName)){
found = i;
break;
}
}
}
}
}
if (found == -1){
config = null;
logger.warn("Did not find "+sectionName+" section in config file. Reverting to defaults.");
}
}
if(config != null && config.getLength() > 0) {
Node node = config.item(found);
if(node.getNodeType() == Node.ELEMENT_NODE){
Element elementEntry = (Element)node;
NodeList childNodeList = elementEntry.getChildNodes();
for (int j = 0; j < childNodeList.getLength(); j++) {
Node node_j = childNodeList.item(j);
if (node_j.getNodeType() == Node.ELEMENT_NODE) {
Element piece = (Element) node_j;
NamedNodeMap attributes = piece.getAttributes();
if (attributes != null && attributes.getLength() > 0){
results.put(attributes.item(0).getNodeValue(), piece.getTextContent());
}
}
}
}
}
return results;
} | java | {
"resource": ""
} |
q6691 | BoneCPConfig.loadClass | train | protected Class<?> loadClass(String clazz) throws ClassNotFoundException {
if (this.classLoader == null){
return Class.forName(clazz);
}
return Class.forName(clazz, true, this.classLoader);
} | java | {
"resource": ""
} |
q6692 | BoneCPConfig.hasSameConfiguration | train | public boolean hasSameConfiguration(BoneCPConfig that){
if ( that != null && Objects.equal(this.acquireIncrement, that.getAcquireIncrement())
&& Objects.equal(this.acquireRetryDelayInMs, that.getAcquireRetryDelayInMs())
&& Objects.equal(this.closeConnectionWatch, that.isCloseConnectionWatch())
&& Objects.equal(this.logStatementsEnabled, that.isLogStatementsEnabled())
&& Objects.equal(this.connectionHook, that.getConnectionHook())
&& Objects.equal(this.connectionTestStatement, that.getConnectionTestStatement())
&& Objects.equal(this.idleConnectionTestPeriodInSeconds, that.getIdleConnectionTestPeriod(TimeUnit.SECONDS))
&& Objects.equal(this.idleMaxAgeInSeconds, that.getIdleMaxAge(TimeUnit.SECONDS))
&& Objects.equal(this.initSQL, that.getInitSQL())
&& Objects.equal(this.jdbcUrl, that.getJdbcUrl())
&& Objects.equal(this.maxConnectionsPerPartition, that.getMaxConnectionsPerPartition())
&& Objects.equal(this.minConnectionsPerPartition, that.getMinConnectionsPerPartition())
&& Objects.equal(this.partitionCount, that.getPartitionCount())
&& Objects.equal(this.releaseHelperThreads, that.getReleaseHelperThreads())
&& Objects.equal(this.statementsCacheSize, that.getStatementsCacheSize())
&& Objects.equal(this.username, that.getUsername())
&& Objects.equal(this.password, that.getPassword())
&& Objects.equal(this.lazyInit, that.isLazyInit())
&& Objects.equal(this.transactionRecoveryEnabled, that.isTransactionRecoveryEnabled())
&& Objects.equal(this.acquireRetryAttempts, that.getAcquireRetryAttempts())
&& Objects.equal(this.statementReleaseHelperThreads, that.getStatementReleaseHelperThreads())
&& Objects.equal(this.closeConnectionWatchTimeoutInMs, that.getCloseConnectionWatchTimeout())
&& Objects.equal(this.connectionTimeoutInMs, that.getConnectionTimeoutInMs())
&& Objects.equal(this.datasourceBean, that.getDatasourceBean())
&& Objects.equal(this.getQueryExecuteTimeLimitInMs(), that.getQueryExecuteTimeLimitInMs())
&& Objects.equal(this.poolAvailabilityThreshold, that.getPoolAvailabilityThreshold())
&& Objects.equal(this.poolName, that.getPoolName())
&& Objects.equal(this.disableConnectionTracking, that.isDisableConnectionTracking())
){
return true;
}
return false;
} | java | {
"resource": ""
} |
q6693 | AbstractConnectionStrategy.preConnection | train | protected long preConnection() throws SQLException{
long statsObtainTime = 0;
if (this.pool.poolShuttingDown){
throw new SQLException(this.pool.shutdownStackTrace);
}
if (this.pool.statisticsEnabled){
statsObtainTime = System.nanoTime();
this.pool.statistics.incrementConnectionsRequested();
}
return statsObtainTime;
} | java | {
"resource": ""
} |
q6694 | AbstractConnectionStrategy.postConnection | train | protected void postConnection(ConnectionHandle handle, long statsObtainTime){
handle.renewConnection(); // mark it as being logically "open"
// Give an application a chance to do something with it.
if (handle.getConnectionHook() != null){
handle.getConnectionHook().onCheckOut(handle);
}
if (this.pool.closeConnectionWatch){ // a debugging tool
this.pool.watchConnection(handle);
}
if (this.pool.statisticsEnabled){
this.pool.statistics.addCumulativeConnectionWaitTime(System.nanoTime()-statsObtainTime);
}
} | java | {
"resource": ""
} |
q6695 | BoneCPDataSource.getPool | train | public BoneCP getPool() {
FinalWrapper<BoneCP> wrapper = this.pool;
return wrapper == null ? null : wrapper.value;
} | java | {
"resource": ""
} |
q6696 | BoneCPConnectionProvider.configure | train | public void configure(Properties props) throws HibernateException {
try{
this.config = new BoneCPConfig(props);
// old hibernate config
String url = props.getProperty(CONFIG_CONNECTION_URL);
String username = props.getProperty(CONFIG_CONNECTION_USERNAME);
String password = props.getProperty(CONFIG_CONNECTION_PASSWORD);
String driver = props.getProperty(CONFIG_CONNECTION_DRIVER_CLASS);
if (url == null){
url = props.getProperty(CONFIG_CONNECTION_URL_ALTERNATE);
}
if (username == null){
username = props.getProperty(CONFIG_CONNECTION_USERNAME_ALTERNATE);
}
if (password == null){
password = props.getProperty(CONFIG_CONNECTION_PASSWORD_ALTERNATE);
}
if (driver == null){
driver = props.getProperty(CONFIG_CONNECTION_DRIVER_CLASS_ALTERNATE);
}
if (url != null){
this.config.setJdbcUrl(url);
}
if (username != null){
this.config.setUsername(username);
}
if (password != null){
this.config.setPassword(password);
}
// Remember Isolation level
this.isolation = ConfigurationHelper.getInteger(AvailableSettings.ISOLATION, props);
this.autocommit = ConfigurationHelper.getBoolean(AvailableSettings.AUTOCOMMIT, props);
logger.debug(this.config.toString());
if (driver != null && !driver.trim().equals("")){
loadClass(driver);
}
if (this.config.getConnectionHookClassName() != null){
Object hookClass = loadClass(this.config.getConnectionHookClassName()).newInstance();
this.config.setConnectionHook((ConnectionHook) hookClass);
}
// create the connection pool
this.pool = createPool(this.config);
} catch (Exception e) {
throw new HibernateException(e);
}
} | java | {
"resource": ""
} |
q6697 | BoneCPConnectionProvider.createPool | train | protected BoneCP createPool(BoneCPConfig config) {
try{
return new BoneCP(config);
} catch (SQLException e) {
throw new HibernateException(e);
}
} | java | {
"resource": ""
} |
q6698 | BoneCPConnectionProvider.mapToProperties | train | private Properties mapToProperties(Map<String, String> map) {
Properties p = new Properties();
for (Map.Entry<String,String> entry : map.entrySet()) {
p.put(entry.getKey(), entry.getValue());
}
return p;
} | java | {
"resource": ""
} |
q6699 | CachedConnectionStrategy.stealExistingAllocations | train | protected synchronized void stealExistingAllocations(){
for (ConnectionHandle handle: this.threadFinalizableRefs.keySet()){
// if they're not in use, pretend they are in use now and close them off.
// this method assumes that the strategy has been flipped back to non-caching mode
// prior to this method invocation.
if (handle.logicallyClosed.compareAndSet(true, false)){
try {
this.pool.releaseConnection(handle);
} catch (SQLException e) {
logger.error("Error releasing connection", e);
}
}
}
if (this.warnApp.compareAndSet(false, true)){ // only issue warning once.
logger.warn("Cached strategy chosen, but more threads are requesting a connection than are configured. Switching permanently to default strategy.");
}
this.threadFinalizableRefs.clear();
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.