_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q14100
ManagedBufferPool.acquire
train
@SuppressWarnings("PMD.GuardLogStatement") public W acquire() throws InterruptedException { // Stop draining, because we obviously need this kind of buffers Optional.ofNullable(idleTimer.getAndSet(null)).ifPresent( timer -> timer.cancel()); if (createdBufs.get() < maximumBufs) { ...
java
{ "resource": "" }
q14101
ManagedBufferPool.recollect
train
@Override public void recollect(W buffer) { if (queue.size() < preservedBufs) { long effectiveDrainDelay = drainDelay > 0 ? drainDelay : defaultDrainDelay; if (effectiveDrainDelay > 0) { // Enqueue buffer.clear(); queue....
java
{ "resource": "" }
q14102
IncludeValue.getIncludedValue
train
public Value getIncludedValue(Environment in){ return ConfigurationManager.INSTANCE.getConfiguration(configurationName, in).getAttribute(attributeName); }
java
{ "resource": "" }
q14103
IncludeValue.getConfigName
train
public ConfigurationSourceKey getConfigName() { return new ConfigurationSourceKey(ConfigurationSourceKey.Type.FILE, ConfigurationSourceKey.Format.JSON, configurationName); }
java
{ "resource": "" }
q14104
Configuration.copyWithIdentifier
train
Configuration copyWithIdentifier(String identifier) { return new Configuration(details.builder().identifier(identifier).build(), new HashMap<>(config)); }
java
{ "resource": "" }
q14105
Configuration.write
train
void write(File f) throws FileNotFoundException, IOException { try (ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(f))) { os.writeObject(this); } }
java
{ "resource": "" }
q14106
ConfigurationSource.fireUpdateEvent
train
public void fireUpdateEvent(final long timestamp){ synchronized(listeners){ for (final ConfigurationSourceListener listener : listeners){ try{ log.debug("Calling configurationSourceUpdated on "+listener); listener.configurationSourceUpdated(this); }catch(final Exception e){ log.error("Error ...
java
{ "resource": "" }
q14107
Inventory.remove
train
InventoryEntry remove(String key) { InventoryEntry ret = configs.remove(key); if (ret!=null) { ret.getPath().delete(); } return ret; }
java
{ "resource": "" }
q14108
Inventory.removeMismatching
train
List<Configuration> removeMismatching() { // List mismatching List<InventoryEntry> mismatching = configs.values().stream() .filter(v-> (v.getConfiguration().isPresent() && !v.getIdentifier().equals(v.getConfiguration().get().getDetails().getKey())) ).collect(Collectors.toList()); // Remove from inve...
java
{ "resource": "" }
q14109
Inventory.removeUnreadable
train
List<File> removeUnreadable() { // List unreadable List<InventoryEntry> unreadable = configs.values() .stream() .filter(v->!v.getConfiguration().isPresent()) .collect(Collectors.toList()); // Remove from inventory unreadable.forEach(v->configs.remove(v.getIdentifier())); // Return the list of remo...
java
{ "resource": "" }
q14110
FormProcessor.onGet
train
@RequestHandler(patterns = "/form,/form/**") public void onGet(Request.In.Get event, IOSubchannel channel) throws ParseException { ResponseCreationSupport.sendStaticContent(event, channel, path -> FormProcessor.class.getResource( ResourcePattern.removeSegments(path, 1...
java
{ "resource": "" }
q14111
FormProcessor.onPost
train
@RequestHandler(patterns = "/form,/form/**") public void onPost(Request.In.Post event, IOSubchannel channel) { FormContext ctx = channel .associated(this, FormContext::new); ctx.request = event.httpRequest(); ctx.session = event.associated(Session.class).get(); event.setR...
java
{ "resource": "" }
q14112
FormProcessor.onInput
train
@Handler public void onInput(Input<ByteBuffer> event, IOSubchannel channel) throws InterruptedException, UnsupportedEncodingException { Optional<FormContext> ctx = channel.associated(this, FormContext.class); if (!ctx.isPresent()) { return; } ctx.get().fieldDe...
java
{ "resource": "" }
q14113
HttpConnector.onConnected
train
@Handler(channels = NetworkChannel.class) @SuppressWarnings("PMD.DataflowAnomalyAnalysis") public void onConnected(Connected event, TcpChannel netConnChannel) throws InterruptedException, IOException { // Check if an app channel has been waiting for such a connection WebAppMsgChannel...
java
{ "resource": "" }
q14114
HttpConnector.onInput
train
@Handler(channels = NetworkChannel.class) public void onInput(Input<ByteBuffer> event, TcpChannel netConnChannel) throws InterruptedException, ProtocolException { Optional<WebAppMsgChannel> appChannel = netConnChannel.associated(WebAppMsgChannel.class); if (appChannel.isPrese...
java
{ "resource": "" }
q14115
HttpConnector.onClosed
train
@Handler(channels = NetworkChannel.class) public void onClosed(Closed event, TcpChannel netConnChannel) { netConnChannel.associated(WebAppMsgChannel.class).ifPresent( appChannel -> appChannel.handleClosed(event)); pooled.remove(netConnChannel.remoteAddress(), netConnChannel); }
java
{ "resource": "" }
q14116
ThymeleafSpringResult.bindStrutsContext
train
Map<String, Object> bindStrutsContext(Object action) { Map<String, Object> variables = new HashMap<String, Object>(); variables.put(ACTION_VARIABLE_NAME, action); if ( action instanceof ActionSupport) { ActionSupport actSupport = (ActionSupport)action; // Struts2 field errors.( Map<fieldname , fiel...
java
{ "resource": "" }
q14117
Settings.sdkInitialize
train
public static synchronized void sdkInitialize(Context context) { if (sdkInitialized == true) { return; } BoltsMeasurementEventListener.getInstance(context.getApplicationContext()); sdkInitialized = true; }
java
{ "resource": "" }
q14118
Settings.getExecutor
train
public static Executor getExecutor() { synchronized (LOCK) { if (Settings.executor == null) { Executor executor = getAsyncTaskExecutor(); if (executor == null) { executor = new ThreadPoolExecutor(DEFAULT_CORE_POOL_SIZE, DEFAULT_MAXIMUM_POOL_SIZE, ...
java
{ "resource": "" }
q14119
Settings.setExecutor
train
public static void setExecutor(Executor executor) { Validate.notNull(executor, "executor"); synchronized (LOCK) { Settings.executor = executor; } }
java
{ "resource": "" }
q14120
Settings.getAttributionId
train
public static String getAttributionId(ContentResolver contentResolver) { try { String [] projection = {ATTRIBUTION_ID_COLUMN_NAME}; Cursor c = contentResolver.query(ATTRIBUTION_ID_CONTENT_URI, projection, null, null, null); if (c == null || !c.moveToFirst()) { ...
java
{ "resource": "" }
q14121
Settings.getLimitEventAndDataUsage
train
public static boolean getLimitEventAndDataUsage(Context context) { SharedPreferences preferences = context.getSharedPreferences(APP_EVENT_PREFERENCES, Context.MODE_PRIVATE); return preferences.getBoolean("limitEventUsage", false); }
java
{ "resource": "" }
q14122
Settings.setLimitEventAndDataUsage
train
public static void setLimitEventAndDataUsage(Context context, boolean limitEventUsage) { SharedPreferences preferences = context.getSharedPreferences(APP_EVENT_PREFERENCES, Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("limitEventUsage", limitEven...
java
{ "resource": "" }
q14123
ToolTipPopup.show
train
public void show() { if (mAnchorViewRef.get() != null) { mPopupContent = new PopupContentView(mContext); TextView body = (TextView) mPopupContent.findViewById( R.id.com_facebook_tooltip_bubble_view_text_body); body.setText(mText); if (mStyle ==...
java
{ "resource": "" }
q14124
UiLifecycleHelper.onCreate
train
public void onCreate(Bundle savedInstanceState) { Session session = Session.getActiveSession(); if (session == null) { if (savedInstanceState != null) { session = Session.restoreSession(activity, null, callback, savedInstanceState); } if (session == nu...
java
{ "resource": "" }
q14125
UiLifecycleHelper.onResume
train
public void onResume() { Session session = Session.getActiveSession(); if (session != null) { if (callback != null) { session.addCallback(callback); } if (SessionState.CREATED_TOKEN_LOADED.equals(session.getState())) { session.openForRe...
java
{ "resource": "" }
q14126
UiLifecycleHelper.onActivityResult
train
public void onActivityResult(int requestCode, int resultCode, Intent data) { onActivityResult(requestCode, resultCode, data, null); }
java
{ "resource": "" }
q14127
UiLifecycleHelper.onActivityResult
train
public void onActivityResult(int requestCode, int resultCode, Intent data, FacebookDialog.Callback facebookDialogCallback) { Session session = Session.getActiveSession(); if (session != null) { session.onActivityResult(activity, requestCode, resultCode, data); } ...
java
{ "resource": "" }
q14128
UiLifecycleHelper.onSaveInstanceState
train
public void onSaveInstanceState(Bundle outState) { Session.saveSession(Session.getActiveSession(), outState); outState.putParcelable(DIALOG_CALL_BUNDLE_SAVE_KEY, pendingFacebookDialogCall); }
java
{ "resource": "" }
q14129
UiLifecycleHelper.onPause
train
public void onPause() { // remove the broadcast receiver broadcastManager.unregisterReceiver(receiver); if (callback != null) { Session session = Session.getActiveSession(); if (session != null) { session.removeCallback(callback); } } ...
java
{ "resource": "" }
q14130
CoreUtils.definitionEvaluator
train
public static Evaluator definitionEvaluator( HandlerDefinition hda) { return definitionEvaluators.computeIfAbsent(hda.evaluator(), key -> { try { return hda.evaluator().getConstructor().newInstance(); } catch (InstantiationException | IllegalAccessException ...
java
{ "resource": "" }
q14131
TaskGroupSpecification.matches
train
public boolean matches(TaskGroupInformation info) { return getActivity().equals(info.getActivity()) && getInputType().equals(info.getInputType()) && getOutputType().equals(info.getOutputType()) && info.matchesLocale(getLocale()); }
java
{ "resource": "" }
q14132
LoggerWrapper.logDomNodeList
train
public void logDomNodeList (String msg, NodeList nodeList) { StackTraceElement caller = StackTraceUtils.getCallerStackTraceElement (); String toLog = (msg != null ? msg + "\n" : "DOM nodelist:\n"); for (int i = 0; i < nodeList.getLength (); i++) { toLog += domNodeDescription (nodeList.item (i), 0) + "\n"; }...
java
{ "resource": "" }
q14133
LoggerWrapper.logDomNode
train
public void logDomNode (String msg, Node node) { StackTraceElement caller = StackTraceUtils.getCallerStackTraceElement (); logDomNode (msg, node, Level.FINER, caller); }
java
{ "resource": "" }
q14134
LoggerWrapper.logDomNode
train
public void logDomNode (String msg, Node node, Level level, StackTraceElement caller) { String toLog = (msg != null ? msg + "\n" : "DOM node:\n") + domNodeDescription (node, 0); if (caller != null) { logger.logp (level, caller.getClassName (), caller.getMethodName () + "():" + caller.getLineNumber (), toLog); ...
java
{ "resource": "" }
q14135
LoggerWrapper.domNodeDescription
train
private String domNodeDescription (Node node, int tablevel) { String domNodeDescription = null; String nodeName = node.getNodeName (); String nodeValue = node.getNodeValue (); if (!(nodeName.equals ("#text") && nodeValue.replaceAll ("\n", "").trim ().equals (""))) { domNodeDescription = tabs (tablevel) + no...
java
{ "resource": "" }
q14136
LoggerWrapper.setLevel
train
public void setLevel (Level level) { this.defaultLevel = level; logger.setLevel (level); for (Handler handler : logger.getHandlers ()) { handler.setLevel (level); } }
java
{ "resource": "" }
q14137
TcpServer.onRegistered
train
@Handler(channels = Self.class) public void onRegistered(NioRegistration.Completed event) throws InterruptedException, IOException { NioHandler handler = event.event().handler(); if (handler == this) { if (event.event().get() == null) { fire(new Error(event, ...
java
{ "resource": "" }
q14138
TcpServer.onClose
train
@Handler @SuppressWarnings("PMD.DataflowAnomalyAnalysis") public void onClose(Close event) throws IOException, InterruptedException { boolean subOnly = true; for (Channel channel : event.channels()) { if (channel instanceof TcpChannelImpl) { if (channels.contains(chan...
java
{ "resource": "" }
q14139
StringUtils.tokenize2vector
train
public static Vector<String> tokenize2vector(final String source, final char delimiter) { final Vector<String> v = new Vector<>(); StringBuilder currentS = new StringBuilder(); char c; for (int i = 0; i < source.length(); i++) { c = source.charAt(i); if (c == delimiter) { v.addElement(currentS.length(...
java
{ "resource": "" }
q14140
StringUtils.removeCComments
train
public static String removeCComments(final String src) { final StringBuilder ret = new StringBuilder(); boolean inComments = false; for (int i = 0; i < src.length(); i++) { char c = src.charAt(i); if (inComments) { if (c == '*' && src.charAt(i + 1) == '/') { inComments = false; i++; } }...
java
{ "resource": "" }
q14141
NativeAppCallAttachmentStore.cleanupAttachmentsForCall
train
public void cleanupAttachmentsForCall(Context context, UUID callId) { File dir = getAttachmentsDirectoryForCall(callId, false); Utility.deleteDirectory(dir); }
java
{ "resource": "" }
q14142
ManagedBuffer.duplicate
train
@SuppressWarnings("unchecked") public final T duplicate() { if (backing instanceof ByteBuffer) { return (T) ((ByteBuffer) backing).duplicate(); } if (backing instanceof CharBuffer) { return (T) ((CharBuffer) backing).duplicate(); } throw new IllegalArg...
java
{ "resource": "" }
q14143
HandlerList.process
train
public void process(EventPipeline eventPipeline, EventBase<?> event) { try { for (HandlerReference hdlr : this) { try { hdlr.invoke(event); if (event.isStopped()) { break; } } catch (A...
java
{ "resource": "" }
q14144
SessionTracker.getOpenSession
train
public Session getOpenSession() { Session openSession = getSession(); if (openSession != null && openSession.isOpened()) { return openSession; } return null; }
java
{ "resource": "" }
q14145
SessionTracker.setSession
train
public void setSession(Session newSession) { if (newSession == null) { if (session != null) { // We're current tracking a Session. Remove the callback // and start tracking the active Session. session.removeCallback(callback); session =...
java
{ "resource": "" }
q14146
SessionTracker.stopTracking
train
public void stopTracking() { if (!isTracking) { return; } Session session = getSession(); if (session != null) { session.removeCallback(callback); } broadcastManager.unregisterReceiver(receiver); isTracking = false; }
java
{ "resource": "" }
q14147
LinkedIOSubchannel.associated
train
@Override @SuppressWarnings("PMD.ShortVariable") public <V> Optional<V> associated(Object by, Class<V> type) { Optional<V> result = super.associated(by, type); if (!result.isPresent()) { IOSubchannel upstream = upstreamChannel(); if (upstream != null) { re...
java
{ "resource": "" }
q14148
FacebookAppLinkResolver.getAppLinkFromUrlInBackground
train
public Task<AppLink> getAppLinkFromUrlInBackground(final Uri uri) { ArrayList<Uri> uris = new ArrayList<Uri>(); uris.add(uri); Task<Map<Uri, AppLink>> resolveTask = getAppLinkFromUrlsInBackground(uris); return resolveTask.onSuccess(new Continuation<Map<Uri, AppLink>, AppLink>() { ...
java
{ "resource": "" }
q14149
BatchFlusher.flush
train
public void flush() { if (eventLoop.inEventLoop()) { pending++; if (pending >= maxPending) { pending = 0; channel.flush(); } } if (woken == 0 && WOKEN.compareAndSet(this, 0, 1)) { woken = 1; eventLoop.execute(wakeup); } }
java
{ "resource": "" }
q14150
InputStreamMonitor.onStart
train
@Handler public void onStart(Start event) { synchronized (this) { if (runner != null) { return; } buffers = new ManagedBufferPool<>(ManagedBuffer::new, () -> { return ByteBuffer.allocateDirect(bufferSize); ...
java
{ "resource": "" }
q14151
InputStreamMonitor.onStop
train
@Handler(priority = -10000) public void onStop(Stop event) throws InterruptedException { synchronized (this) { if (runner == null) { return; } runner.interrupt(); synchronized (this) { if (registered) { unreg...
java
{ "resource": "" }
q14152
ComponentVertex.componentVertex
train
public static ComponentVertex componentVertex( ComponentType component, Channel componentChannel) { if (component instanceof ComponentVertex) { return (ComponentVertex) component; } return ComponentProxy.getComponentProxy(component, componentChannel); }
java
{ "resource": "" }
q14153
ComponentVertex.setTree
train
private void setTree(ComponentTree tree) { synchronized (this) { this.tree = tree; for (ComponentVertex child : children) { child.setTree(tree); } } }
java
{ "resource": "" }
q14154
ComponentVertex.collectHandlers
train
@SuppressWarnings("PMD.UseVarargs") /* default */ void collectHandlers(Collection<HandlerReference> hdlrs, EventBase<?> event, Channel[] channels) { for (HandlerReference hdlr : handlers) { if (hdlr.handles(event, channels)) { hdlrs.add(hdlr); } } ...
java
{ "resource": "" }
q14155
PlacePickerFragment.getSelection
train
public GraphPlace getSelection() { Collection<GraphPlace> selection = getSelectedGraphObjects(); return (selection != null && !selection.isEmpty()) ? selection.iterator().next() : null; }
java
{ "resource": "" }
q14156
FieldErrorAttributeProcessor.hasFieldError
train
protected boolean hasFieldError(String fieldname) { if ( StringUtils.isEmpty(fieldname)) { return false; } Object action = ActionContext.getContext().getActionInvocation().getAction(); // check action instance 'ActionSupport'. if (!(action instanceof ActionSupport)) { return false; } Ac...
java
{ "resource": "" }
q14157
FieldErrorAttributeProcessor.getFieldValue
train
protected Object getFieldValue(String fieldname) { ActionContext actionCtx = ActionContext.getContext(); ValueStack valueStack = actionCtx.getValueStack(); Object value = valueStack.findValue(fieldname, false); String overwriteValue = getOverwriteValue(fieldname); if ( overwriteValue != null ) { ...
java
{ "resource": "" }
q14158
FieldErrorAttributeProcessor.getOverwriteValue
train
protected String getOverwriteValue(String fieldname) { ActionContext ctx = ServletActionContext.getContext(); ValueStack stack = ctx.getValueStack(); Map<Object ,Object> overrideMap = stack.getExprOverrides(); // If convertion error has not, do nothing. if ( overrideMap == null || overrideMap.isEmpty()...
java
{ "resource": "" }
q14159
ProfilePictureView.setPresetSize
train
public final void setPresetSize(int sizeType) { switch (sizeType) { case SMALL: case NORMAL: case LARGE: case CUSTOM: this.presetSizeType = sizeType; break; default: throw new IllegalArgumentException("M...
java
{ "resource": "" }
q14160
ProfilePictureView.setProfileId
train
public final void setProfileId(String profileId) { boolean force = false; if (Utility.isNullOrEmpty(this.profileId) || !this.profileId.equalsIgnoreCase(profileId)) { // Clear out the old profilePicture before requesting for the new one. setBlankProfilePicture(); force...
java
{ "resource": "" }
q14161
ProfilePictureView.onSaveInstanceState
train
@Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); Bundle instanceState = new Bundle(); instanceState.putParcelable(SUPER_STATE_KEY, superState); instanceState.putString(PROFILE_ID_KEY, profileId); instanceState.putInt(...
java
{ "resource": "" }
q14162
ProfilePictureView.onRestoreInstanceState
train
@Override protected void onRestoreInstanceState(Parcelable state) { if (state.getClass() != Bundle.class) { super.onRestoreInstanceState(state); } else { Bundle instanceState = (Bundle)state; super.onRestoreInstanceState(instanceState.getParcelable(SUPER_STATE_KEY...
java
{ "resource": "" }
q14163
PeasyRecyclerView.enhanceFAB
train
private void enhanceFAB(final FloatingActionButton fab, int dx, int dy) { if (isEnhancedFAB() && getFab() != null) { final FloatingActionButton mFloatingActionButton = this.fab; if (getLinearLayoutManager() != null) { if (dy > 0) { if (mFloatingActionB...
java
{ "resource": "" }
q14164
PeasyRecyclerView.enhanceFAB
train
private void enhanceFAB(final FloatingActionButton fab, MotionEvent e) { if (hasAllItemsShown()) { if (fab.getVisibility() != View.VISIBLE) { fab.show(); } } }
java
{ "resource": "" }
q14165
PeasyRecyclerView.getHeaderViewType
train
private int getHeaderViewType(int position) { if (headerContent != null) { if (headerContent.getData() == getItem(position) && (position == 0)) { return headerContent.getViewtype(); } } return PeasyHeaderViewHolder.VIEWTYPE_NOTHING; }
java
{ "resource": "" }
q14166
PeasyRecyclerView.getFooterViewType
train
public int getFooterViewType(int position) { if (footerContent != null) { if (footerContent.getData() == getItem(position) && (position == getLastItemIndex())) { return footerContent.getViewtype(); } } return PeasyHeaderViewHolder.VIEWTYPE_NOTHING; }
java
{ "resource": "" }
q14167
PeasyRecyclerView.onItemLongClick
train
public boolean onItemLongClick(final View view, final int viewType, final int position, final T item, final PeasyViewHolder viewHolder) { return true; }
java
{ "resource": "" }
q14168
ResponseCreationSupport.sendStaticContent
train
@SuppressWarnings({ "PMD.NcssCount", "PMD.UseStringBufferForStringAppends" }) public static boolean sendStaticContent( HttpRequest request, IOSubchannel channel, Function<String, URL> resolver, MaxAgeCalculator maxAgeCalculator) { String path = request.requestUri().getPath();...
java
{ "resource": "" }
q14169
ResponseCreationSupport.resourceInfo
train
@SuppressWarnings("PMD.EmptyCatchBlock") public static ResourceInfo resourceInfo(URL resource) { try { Path path = Paths.get(resource.toURI()); return new ResourceInfo(Files.isDirectory(path), Files.getLastModifiedTime(path).toInstant() .with(Chron...
java
{ "resource": "" }
q14170
ResponseCreationSupport.setMaxAge
train
public static long setMaxAge(HttpResponse response, int maxAge) { List<Directive> directives = new ArrayList<>(); directives.add(new Directive("max-age", maxAge)); response.setField(HttpField.CACHE_CONTROL, directives); return maxAge; }
java
{ "resource": "" }
q14171
FriendPickerFragment.setSelection
train
public void setSelection(List<GraphUser> graphUsers) { List<String> userIds = new ArrayList<String>(); for(GraphUser graphUser: graphUsers) { userIds.add(graphUser.getId()); } setSelectionByIds(userIds); }
java
{ "resource": "" }
q14172
Facebook.authorize
train
private void authorize(Activity activity, String[] permissions, int activityCode, SessionLoginBehavior behavior, final DialogListener listener) { checkUserSession("authorize"); pendingOpeningSession = new Session.Builder(activity). setApplicationId(mAppId). ...
java
{ "resource": "" }
q14173
Facebook.validateServiceIntent
train
private boolean validateServiceIntent(Context context, Intent intent) { ResolveInfo resolveInfo = context.getPackageManager().resolveService(intent, 0); if (resolveInfo == null) { return false; } return validateAppSignatureForPackage(context, resolveInfo.serviceInfo.packageN...
java
{ "resource": "" }
q14174
Facebook.validateAppSignatureForPackage
train
private boolean validateAppSignatureForPackage(Context context, String packageName) { PackageInfo packageInfo; try { packageInfo = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES); } catch (NameNotFoundException e) { return false; ...
java
{ "resource": "" }
q14175
Facebook.requestImpl
train
@SuppressWarnings("deprecation") String requestImpl(String graphPath, Bundle params, String httpMethod) throws FileNotFoundException, MalformedURLException, IOException { params.putString("format", "json"); if (isSessionValid()) { params.putString(TOKEN, getAccessToken()); ...
java
{ "resource": "" }
q14176
Facebook.setSession
train
@Deprecated public void setSession(Session session) { if (session == null) { throw new IllegalArgumentException("session cannot be null"); } synchronized (this.lock) { this.userSetSession = session; } }
java
{ "resource": "" }
q14177
Facebook.getSession
train
@Deprecated public final Session getSession() { while (true) { String cachedToken = null; Session oldSession = null; synchronized (this.lock) { if (userSetSession != null) { return userSetSession; } if (...
java
{ "resource": "" }
q14178
NioDispatcher.onStart
train
@Handler public void onStart(Start event) { synchronized (this) { if (runner != null && !runner.isInterrupted()) { return; } runner = new Thread(this, Components.simpleObjectName(this)); runner.start(); } }
java
{ "resource": "" }
q14179
NioDispatcher.onStop
train
@Handler(priority = -10000) public void onStop(Stop event) throws InterruptedException { synchronized (this) { if (runner == null) { return; } // It just might happen that the wakeup() occurs between the // check for running and the select() in...
java
{ "resource": "" }
q14180
NioDispatcher.onNioRegistration
train
@Handler public void onNioRegistration(NioRegistration event) throws IOException { SelectableChannel channel = event.ioChannel(); channel.configureBlocking(false); SelectionKey key; synchronized (selectorGate) { selector.wakeup(); // make sure selector isn't b...
java
{ "resource": "" }
q14181
ScanStrategy.innerJoin
train
private DataContainer innerJoin(DataContainer left, DataContainer right, Optional<BooleanExpression> joinCondition) { return crossJoin(left, right, joinCondition, JoinType.INNER); }
java
{ "resource": "" }
q14182
SessionManager.derivePattern
train
@SuppressWarnings("PMD.DataflowAnomalyAnalysis") protected static String derivePattern(String path) { String pattern; if ("/".equals(path)) { pattern = "/**"; } else { String patternBase = path; if (patternBase.endsWith("/")) { patternBase ...
java
{ "resource": "" }
q14183
SessionManager.createSessionId
train
protected String createSessionId(HttpResponse response) { StringBuilder sessionIdBuilder = new StringBuilder(); byte[] bytes = new byte[16]; secureRandom.nextBytes(bytes); for (byte b : bytes) { sessionIdBuilder.append(Integer.toHexString(b & 0xff)); } String ...
java
{ "resource": "" }
q14184
SessionManager.discard
train
@Handler(channels = Channel.class) public void discard(DiscardSession event) { removeSession(event.session().id()); }
java
{ "resource": "" }
q14185
SessionManager.onProtocolSwitchAccepted
train
@Handler(priority = 1000) public void onProtocolSwitchAccepted( ProtocolSwitchAccepted event, IOSubchannel channel) { event.requestEvent().associated(Session.class) .ifPresent(session -> { channel.setAssociated(Session.class, session); }); }
java
{ "resource": "" }
q14186
TcpConnector.onOpenConnection
train
@Handler public void onOpenConnection(OpenTcpConnection event) { try { SocketChannel socketChannel = SocketChannel.open(event.address()); channels.add(new TcpChannelImpl(socketChannel)); } catch (ConnectException e) { fire(new ConnectError(event, "Connection refus...
java
{ "resource": "" }
q14187
TcpConnector.onRegistered
train
@Handler(channels = Self.class) public void onRegistered(NioRegistration.Completed event) throws InterruptedException, IOException { NioHandler handler = event.event().handler(); if (!(handler instanceof TcpChannelImpl)) { return; } if (event.event().get() == ...
java
{ "resource": "" }
q14188
TcpConnector.onClose
train
@Handler @SuppressWarnings("PMD.DataflowAnomalyAnalysis") public void onClose(Close event) throws IOException, InterruptedException { for (Channel channel : event.channels()) { if (channel instanceof TcpChannelImpl && channels.contains(channel)) { ((TcpChannel...
java
{ "resource": "" }
q14189
ValidatorFactoryMaker.newValidator
train
@Override public Validator newValidator(String identifier) { if (identifier==null) { return null; } ValidatorFactory template; synchronized (map) { verifyMapIntegrity(); template = map.get(identifier); } if (template!=null) { try { return template.newValidator(identifier); } catch (Valid...
java
{ "resource": "" }
q14190
ResourcePattern.matches
train
@SuppressWarnings({ "PMD.CyclomaticComplexity", "PMD.NPathComplexity", "PMD.CollapsibleIfStatements", "PMD.DataflowAnomalyAnalysis" }) public int matches(URI resource) { if (protocol != null && !protocol.equals("*")) { if (resource.getScheme() == null) { return -1; ...
java
{ "resource": "" }
q14191
ResourcePattern.matches
train
public static boolean matches(String pattern, URI resource) throws ParseException { return (new ResourcePattern(pattern)).matches(resource) >= 0; }
java
{ "resource": "" }
q14192
StaticContentDispatcher.onGet
train
@RequestHandler(dynamic = true) public void onGet(Request.In.Get event, IOSubchannel channel) throws ParseException, IOException { int prefixSegs = resourcePattern.matches(event.requestUri()); if (prefixSegs < 0) { return; } if (contentDirectory == null) { ...
java
{ "resource": "" }
q14193
EchoUntilQuit.onInput
train
@Handler @SuppressWarnings("PMD.SystemPrintln") public void onInput(Input<ByteBuffer> event) { String data = Charset.defaultCharset().decode(event.data()).toString(); System.out.print(data); if (data.trim().equals("QUIT")) { fire(new Stop()); } }
java
{ "resource": "" }
q14194
ConfigurationUpdate.removePath
train
public ConfigurationUpdate removePath(String path) { if (path == null || !path.startsWith("/")) { throw new IllegalArgumentException("Path must start with \"/\"."); } paths.put(path, null); return this; }
java
{ "resource": "" }
q14195
ConfigurationUpdate.values
train
public Optional<Map<String,String>> values(String path) { Map<String,String> result = paths.get(path); if (result == null) { return Optional.empty(); } return Optional.of(Collections.unmodifiableMap(result)); }
java
{ "resource": "" }
q14196
ConfigurationUpdate.value
train
public Optional<String> value(String path, String key) { return Optional.ofNullable(paths.get(path)) .flatMap(map -> Optional.ofNullable(map.get(key))); }
java
{ "resource": "" }
q14197
TextUtils.isRange
train
public static boolean isRange(String value) { if (value == null) { return false; } try { Set<Integer> values = parseRange(value); return values.size() > 0; } catch (Exception e) { return false; } }
java
{ "resource": "" }
q14198
SSLTools.disableSSLValidation
train
public static void disableSSLValidation() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init(null, new TrustManager[]{new UnsafeTrustManager()}, null); HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory()); } catch (Exception e) { throw new Runti...
java
{ "resource": "" }
q14199
SSLTools.enableSSLValidation
train
public static void enableSSLValidation() { try { SSLContext.getInstance("SSL").init(null, null, null); } catch (Exception e) { throw new RuntimeException(e); } }
java
{ "resource": "" }