ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/websocket/WsRemoteEndpointImplClient.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/websocket/WsRemoteEndpointImplClient.java
Status
scanned
Type
file
Name
WsRemoteEndpointImplClient.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
3286 (3.2 KB)
MD5
9a1e8c6bce34000a9fe97f1ae4780263
SHA1
2fa7147df58651dd20d94b40c108346d94f08d77
SHA256
9dadb49bde8f96796d6956f100f4c6195f0481b76bab5c574986c2880a774a4f
SHA512

      
    
SHA1_git
bbf3885dccedc424f14ab3cc23d94aba745d376b
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
WsRemoteEndpointImplClient.java | 3.2 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.websocket; import java.io.IOException; import java.nio.ByteBuffer; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.locks.ReentrantLock; import jakarta.websocket.SendHandler; import jakarta.websocket.SendResult; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; public class WsRemoteEndpointImplClient extends WsRemoteEndpointImplBase { private final Log log = LogFactory.getLog(WsRemoteEndpointImplClient.class); // must not be static private final AsyncChannelWrapper channel; private final ReentrantLock lock = new ReentrantLock(); public WsRemoteEndpointImplClient(AsyncChannelWrapper channel) { this.channel = channel; } @Override protected boolean isMasked() { return true; } @Override protected void doWrite(SendHandler handler, long blockingWriteTimeoutExpiry, ByteBuffer... data) { long timeout; for (ByteBuffer byteBuffer : data) { if (blockingWriteTimeoutExpiry == -1) { timeout = getSendTimeout(); if (timeout < 1) { timeout = Long.MAX_VALUE; } } else { timeout = blockingWriteTimeoutExpiry - System.currentTimeMillis(); if (timeout < 0) { SendResult sr = new SendResult(getSession(), new IOException(sm.getString("wsRemoteEndpoint.writeTimeout"))); handler.onResult(sr); return; } } try { channel.write(byteBuffer).get(timeout, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { log.warn(sm.getString("wsRemoteEndpointClient.writeFailed", Long.valueOf(blockingWriteTimeoutExpiry), Long.valueOf(timeout)), e); handler.onResult(new SendResult(getSession(), e)); return; } } handler.onResult(new SendResult(getSession())); } @Override protected void doClose() { channel.close(); } @Override protected ReentrantLock getLock() { return lock; } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
38.14
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9