proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/diff/ChangeDelta.java | ChangeDelta | applyTo | class ChangeDelta<T> extends Delta<T> {
/**
* Creates a change delta with the two given chunks.
* @param original The original chunk. Must not be {@code null}.
* @param revised The original chunk. Must not be {@code null}.
*/
public ChangeDelta(Chunk<T> original, Chunk<T> revised) {
super(original,... |
verify(target);
int position = getOriginal().getPosition();
int size = getOriginal().size();
for (int i = 0; i < size; i++) {
target.remove(position);
}
int i = 0;
for (T line : getRevised().getLines()) {
target.add(position + i, line);
i++;
}
| 262 | 101 | 363 | <methods>public void <init>(Chunk<T>, Chunk<T>) ,public abstract void applyTo(List<T>) throws java.lang.IllegalStateException,public boolean equals(java.lang.Object) ,public Chunk<T> getOriginal() ,public Chunk<T> getRevised() ,public abstract org.assertj.core.util.diff.Delta.TYPE getType() ,public int hashCode() ,publ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/diff/Chunk.java | Chunk | equals | class Chunk<T> {
private final int position;
private List<T> lines;
/**
* Creates a chunk and saves a copy of affected lines
*
* @param position
* the start position
* @param lines
* the affected lines
*/
public Chunk(int position, List<T> lines) {
this.position... |
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
@SuppressWarnings("rawtypes")
Chunk other = (Chunk) obj;
if (lines == null) {
if (other.lines != null)
return false;
} else if (!lines.equals(other.li... | 589 | 125 | 714 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/diff/DeleteDelta.java | DeleteDelta | applyTo | class DeleteDelta<T> extends Delta<T> {
/**
* Creates a change delta with the two given chunks.
*
* @param original
* The original chunk. Must not be {@code null}.
* @param revised
* The original chunk. Must not be {@code null}.
*/
public DeleteDelta(Chunk<T> original, Ch... |
verify(target);
int position = getOriginal().getPosition();
int size = getOriginal().size();
for (int i = 0; i < size; i++) {
target.remove(position);
}
| 229 | 58 | 287 | <methods>public void <init>(Chunk<T>, Chunk<T>) ,public abstract void applyTo(List<T>) throws java.lang.IllegalStateException,public boolean equals(java.lang.Object) ,public Chunk<T> getOriginal() ,public Chunk<T> getRevised() ,public abstract org.assertj.core.util.diff.Delta.TYPE getType() ,public int hashCode() ,publ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/diff/Delta.java | Delta | equals | class Delta<T> {
public static final String DEFAULT_END = "]";
public static final String DEFAULT_START = "[";
/** The original chunk. */
private Chunk<T> original;
/** The revised chunk. */
private Chunk<T> revised;
/**
* Specifies the type of the delta.
*
*/
public enum TYPE {
/** A c... |
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
Delta<?> other = (Delta<?>) obj;
return Objects.equals(original, other.original) && Objects.equals(revised, other.revised);
| 667 | 87 | 754 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/diff/DeltaComparator.java | DeltaComparator | compare | class DeltaComparator implements Comparator<Delta<?>>, Serializable {
private static final long serialVersionUID = 1L;
public static final Comparator<Delta<?>> INSTANCE = new DeltaComparator();
private DeltaComparator() {}
@Override
public int compare(final Delta<?> a, final Delta<?> b) {<FILL_FUNCTION_BODY... |
final int posA = a.getOriginal().getPosition();
final int posB = b.getOriginal().getPosition();
if (posA > posB) {
return 1;
} else if (posA < posB) {
return -1;
}
return 0;
| 110 | 78 | 188 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/diff/InsertDelta.java | InsertDelta | applyTo | class InsertDelta<T> extends Delta<T> {
/**
* Creates an insert delta with the two given chunks.
*
* @param original
* The original chunk. Must not be {@code null}.
* @param revised
* The original chunk. Must not be {@code null}.
*/
public InsertDelta(Chunk<T> original, C... |
verify(target);
int position = this.getOriginal().getPosition();
List<T> lines = this.getRevised().getLines();
for (int i = 0; i < lines.size(); i++) {
target.add(position + i, lines.get(i));
}
| 248 | 78 | 326 | <methods>public void <init>(Chunk<T>, Chunk<T>) ,public abstract void applyTo(List<T>) throws java.lang.IllegalStateException,public boolean equals(java.lang.Object) ,public Chunk<T> getOriginal() ,public Chunk<T> getRevised() ,public abstract org.assertj.core.util.diff.Delta.TYPE getType() ,public int hashCode() ,publ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/diff/Patch.java | Patch | applyTo | class Patch<T> {
private List<Delta<T>> deltas = new LinkedList<>();
/**
* Apply this patch to the given target
* @param target the list to patch
* @return the patched text
* @throws IllegalStateException if can't apply patch
*/
public List<T> applyTo(List<T> target) throws IllegalStateException {... |
List<T> result = new LinkedList<>(target);
ListIterator<Delta<T>> it = getDeltas().listIterator(deltas.size());
while (it.hasPrevious()) {
Delta<T> delta = it.previous();
delta.applyTo(result);
}
return result;
| 236 | 83 | 319 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/diff/myers/MyersDiff.java | MyersDiff | buildPath | class MyersDiff<T> implements DiffAlgorithm<T> {
/** The equalizer. */
private final Equalizer<T> equalizer;
/**
* Constructs an instance of the Myers differencing algorithm.
*/
public MyersDiff() {
/* Default equalizer. */
equalizer = Object::equals;
}
/**
* {@inheritDoc}
*
* Retu... |
checkArgument(orig != null, "original sequence is null");
checkArgument(rev != null, "revised sequence is null");
// these are local constants
final int N = orig.size();
final int M = rev.size();
final int MAX = N + M + 1;
final int size = 1 + 2 * MAX;
final int middle = size / 2;
... | 1,057 | 520 | 1,577 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/diff/myers/PathNode.java | PathNode | previousSnake | class PathNode {
/** Position in the original sequence. */
public final int i;
/** Position in the revised sequence. */
public final int j;
/** The previous node in the path. */
public final PathNode prev;
/**
* Concatenates a new path node with an existing diffpath.
* @param i The position in the... |
if (isBootstrap())
return null;
if (!isSnake() && prev != null)
return prev.previousSnake();
return this;
| 535 | 44 | 579 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/introspection/CaseFormatUtils.java | CaseFormatUtils | adjustWordCase | class CaseFormatUtils {
private static final String WORD_SEPARATOR_REGEX = "[ _-]";
private CaseFormatUtils() {}
/**
* Converts an input string into camelCase.
* <p>
* The input string may use any of the well known case styles: Pascal, Snake, Kebab or even Camel.
* Already camelCased strings will ... |
String firstLetter = s.substring(0, 1);
String trailingLetters = s.substring(1);
return (firstLetterUpperCased ? firstLetter.toUpperCase() : firstLetter.toLowerCase()) +
(isAllCaps(s) ? trailingLetters.toLowerCase() : trailingLetters);
| 433 | 92 | 525 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/introspection/ClassUtils.java | ClassUtils | getAllSuperclasses | class ClassUtils {
/**
* Lists primitive wrapper {@link Class}es.
*/
private static final List<Class<?>> PRIMITIVE_WRAPPER_TYPES = list(Boolean.class, Byte.class, Character.class, Short.class,
Integer.class, Long.class, Double.class, Float.... |
if (cls == null) {
return null;
}
final List<Class<?>> classes = new ArrayList<>();
Class<?> superclass = cls.getSuperclass();
while (superclass != null) {
classes.add(superclass);
superclass = superclass.getSuperclass();
}
return classes;
| 1,272 | 91 | 1,363 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/introspection/FieldUtils.java | FieldUtils | readField | class FieldUtils {
// use ConcurrentHashMap as FieldUtils can be used in a multi-thread context
private static final Map<Class<?>, Map<String, Field>> fieldsPerClass = new ConcurrentHashMap<>();
/**
* Gets an accessible <code>Field</code> by name breaking scope if requested. Superclasses/interfaces will be
... |
checkArgument(target != null, "target object must not be null");
Class<?> cls = target.getClass();
Field field = getField(cls, fieldName, forceAccess);
checkArgument(field != null, "Cannot locate field %s on %s", fieldName, cls);
checkArgument(!isStatic(field.getModifiers()), "Reading static field ... | 1,564 | 169 | 1,733 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/introspection/Introspection.java | MethodKey | equals | class MethodKey {
private final String name;
private final Class<?> clazz;
private MethodKey(final String name, final Class<?> clazz) {
this.name = name;
this.clazz = clazz;
}
@Override
public boolean equals(final Object o) {<FILL_FUNCTION_BODY>}
@Override
public int hashC... |
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final MethodKey methodKey = (MethodKey) o;
return Objects.equals(name, methodKey.name) && Objects.equals(clazz, methodKey.clazz);
| 124 | 79 | 203 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/introspection/MemberUtils.java | MemberUtils | setAccessibleWorkaround | class MemberUtils {
private static final int ACCESS_TEST = Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE;
/**
* XXX Default access superclass workaround
*
* When a public class has a default access superclass with public members,
* these members are accessible. Calling them from compiled cod... |
if (o == null || o.isAccessible()) {
return;
}
Member m = (Member) o;
if (Modifier.isPublic(m.getModifiers())
&& isPackageAccess(m.getDeclaringClass().getModifiers())) {
try {
o.setAccessible(true);
} catch (SecurityException e) { // NOPMD
// ignore in favor of... | 292 | 115 | 407 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/introspection/MethodSupport.java | MethodSupport | methodResultFor | class MethodSupport {
private static final String METHOD_HAS_NO_RETURN_VALUE = "Method '%s' in class %s.class has to return a value!";
private static final String METHOD_NOT_FOUND = "Can't find method '%s' in class %s.class. Make sure public method " +
"exists and a... |
requireNonNull(instance, "Object instance can not be null!");
checkNotNullOrEmpty(methodName, "Method name can not be empty!");
Method method = findMethod(methodName, instance.getClass());
return invokeMethod(instance, method);
| 576 | 65 | 641 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/introspection/PropertyOrFieldSupport.java | PropertyOrFieldSupport | getValueOf | class PropertyOrFieldSupport {
private static final String SEPARATOR = ".";
private PropertySupport propertySupport;
private FieldSupport fieldSupport;
public static final PropertyOrFieldSupport EXTRACTION = new PropertyOrFieldSupport();
public static final PropertyOrFieldSupport COMPARISON = new PropertyOrF... |
checkArgument(propertyOrFieldName != null, "The name of the property/field to read should not be null");
checkArgument(!propertyOrFieldName.isEmpty(), "The name of the property/field to read should not be empty");
checkArgument(input != null, "The object to extract property/field from should not be null");... | 828 | 222 | 1,050 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/xml/XmlStringPrettyFormatter.java | XmlStringPrettyFormatter | prettyFormat | class XmlStringPrettyFormatter {
private static final String FORMAT_ERROR = "Unable to format XML string";
public static String xmlPrettyFormat(String xmlStringToFormat) {
checkArgument(xmlStringToFormat != null, "Expecting XML String not to be null");
// convert String to an XML Document and then back to... |
try {
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
DOMImplementationLS domImplementation = (DOMImplementationLS) registry.getDOMImplementation("LS");
Writer stringWriter = new StringWriter();
LSOutput formattedOutput = domImplementation.createLSOutput();
... | 275 | 211 | 486 | <no_super_class> |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/api/ByteSourceAssert.java | ByteSourceAssert | hasSize | class ByteSourceAssert extends AbstractAssert<ByteSourceAssert, ByteSource> {
protected ByteSourceAssert(ByteSource actual) {
super(actual, ByteSourceAssert.class);
}
/**
* Verifies that the actual {@link ByteSource} has the same content as the provided one.<br>
* <p>
* Example :
* <pre><code cl... |
isNotNull();
long sizeOfActual = actual.size();
if (sizeOfActual != expectedSize) throw assertionError(shouldHaveSize(actual, sizeOfActual, expectedSize));
return this;
| 724 | 53 | 777 | <methods>public ASSERT asInstanceOf(InstanceOfAssertFactory<?,ASSERT>) ,public AbstractListAssert<?,List<?>,java.lang.Object,ObjectAssert<java.lang.Object>> asList() ,public AbstractStringAssert<?> asString() ,public org.assertj.guava.api.ByteSourceAssert describedAs(org.assertj.core.description.Description) ,public ja... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/api/MultisetAssert.java | MultisetAssert | contains | class MultisetAssert<T> extends AbstractIterableAssert<MultisetAssert<T>, Multiset<? extends T>, T, ObjectAssert<T>> {
protected MultisetAssert(Multiset<? extends T> actual) {
super(actual, MultisetAssert.class);
}
/**
* Verifies the actual {@link Multiset} contains the given value <b>exactly</b> the giv... |
isNotNull();
checkArgument(expectedCount >= 0, "The expected count should not be negative.");
int actualCount = actual.count(expected);
if (actualCount != expectedCount) {
throw assertionError(shouldContainTimes(actual, expected, expectedCount, actualCount));
}
return myself;
| 1,297 | 80 | 1,377 | <methods>public MultisetAssert<T> allMatch(Predicate<? super T>) ,public MultisetAssert<T> allMatch(Predicate<? super T>, java.lang.String) ,public MultisetAssert<T> allSatisfy(Consumer<? super T>) ,public MultisetAssert<T> allSatisfy(ThrowingConsumer<? super T>) ,public MultisetAssert<T> anyMatch(Predicate<? super T>)... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/api/OptionalAssert.java | OptionalAssert | isPresent | class OptionalAssert<T> extends AbstractAssert<OptionalAssert<T>, Optional<T>> {
protected OptionalAssert(final Optional<T> actual) {
super(actual, OptionalAssert.class);
}
// visible for test
protected Optional<T> getActual() {
return actual;
}
/**
* Verifies that the actual {@link Optional} ... |
isNotNull();
if (!actual.isPresent()) {
throw assertionError(shouldBePresent(actual));
}
return this;
| 1,199 | 38 | 1,237 | <methods>public ASSERT asInstanceOf(InstanceOfAssertFactory<?,ASSERT>) ,public AbstractListAssert<?,List<?>,java.lang.Object,ObjectAssert<java.lang.Object>> asList() ,public AbstractStringAssert<?> asString() ,public OptionalAssert<T> describedAs(org.assertj.core.description.Description) ,public java.lang.String descri... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/data/MapEntry.java | MapEntry | hashCode | class MapEntry<K, V> {
public final K key;
public final V value;
/**
* Creates a new {@link MapEntry}.
*
* @param <K> key type
* @param <V> value type
* @param key the key of the entry to create.
* @param value the value of the entry to create.
* @return the created {@code MapEntry}.
*/
... |
int result = 1;
result = HASH_CODE_PRIME * result + hashCodeFor(key);
result = HASH_CODE_PRIME * result + hashCodeFor(value);
return result;
| 375 | 55 | 430 | <no_super_class> |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/MultisetShouldContainAtLeastTimes.java | MultisetShouldContainAtLeastTimes | shouldContainAtLeastTimes | class MultisetShouldContainAtLeastTimes extends BasicErrorMessageFactory {
public static ErrorMessageFactory shouldContainAtLeastTimes(final Multiset<?> actual, final Object expected,
final int expectedTimes, final int actualTimes) {<FILL_FUNCTION_BODY>}
... |
return new MultisetShouldContainAtLeastTimes("%n" +
"Expecting:%n" +
" %s%n" +
"to contain:%n" +
" %s%n" +
... | 110 | 95 | 205 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/MultisetShouldContainAtMostTimes.java | MultisetShouldContainAtMostTimes | shouldContainAtMostTimes | class MultisetShouldContainAtMostTimes extends BasicErrorMessageFactory {
public static ErrorMessageFactory shouldContainAtMostTimes(final Multiset<?> actual, final Object expected,
final int expectedTimes, final int actualTimes) {<FILL_FUNCTION_BODY>}
... |
return new MultisetShouldContainAtMostTimes("%n" +
"Expecting:%n" +
" %s%n" +
"to contain:%n" +
" %s%n" +
... | 106 | 88 | 194 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/MultisetShouldContainTimes.java | MultisetShouldContainTimes | shouldContainTimes | class MultisetShouldContainTimes extends BasicErrorMessageFactory {
public static ErrorMessageFactory shouldContainTimes(final Multiset<?> actual, final Object expected,
final int expectedTimes, final int actualTimes) {<FILL_FUNCTION_BODY>}
private MultisetSh... |
return new MultisetShouldContainTimes("%n" +
"Expecting:%n" +
" %s%n" +
"to contain:%n" +
" %s%n" +
"ex... | 100 | 86 | 186 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/OptionalShouldBeAbsent.java | OptionalShouldBeAbsent | shouldBeAbsent | class OptionalShouldBeAbsent extends BasicErrorMessageFactory {
public static <T> ErrorMessageFactory shouldBeAbsent(final Optional<T> actual) {<FILL_FUNCTION_BODY>}
private OptionalShouldBeAbsent(final String format, final Object... arguments) {
super(format, arguments);
}
} |
return new OptionalShouldBeAbsent("Expecting Optional to contain nothing (absent Optional) but contained %s",
actual.get());
| 83 | 36 | 119 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/OptionalShouldBePresent.java | OptionalShouldBePresent | shouldBePresent | class OptionalShouldBePresent extends BasicErrorMessageFactory {
public static <T> ErrorMessageFactory shouldBePresent(final Optional<T> actual) {<FILL_FUNCTION_BODY>}
private OptionalShouldBePresent(final String format, final Object... arguments) {
super(format, arguments);
}
} |
return new OptionalShouldBePresent(
"Expecting Optional to contain a non-null instance but contained nothing (absent Optional)",
actual);
| 80 | 38 | 118 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/OptionalShouldBePresentWithValue.java | OptionalShouldBePresentWithValue | shouldBePresentWithValue | class OptionalShouldBePresentWithValue extends BasicErrorMessageFactory {
public static <T> ErrorMessageFactory shouldBePresentWithValue(final Optional<T> actual, final Object value) {<FILL_FUNCTION_BODY>}
public static <T> ErrorMessageFactory shouldBePresentWithValue(final Object value) {
return new Optional... |
return new OptionalShouldBePresentWithValue("%nExpecting Optional to contain value %n %s%n but contained %n %s",
value, actual.get());
| 149 | 45 | 194 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/RangeShouldBeClosedInTheLowerBound.java | RangeShouldBeClosedInTheLowerBound | shouldHaveClosedLowerBound | class RangeShouldBeClosedInTheLowerBound extends BasicErrorMessageFactory {
public static <T extends Comparable<T>> ErrorMessageFactory shouldHaveClosedLowerBound(final Range<T> actual) {<FILL_FUNCTION_BODY>}
/**
* Creates a new <code>{@link org.assertj.core.error.BasicErrorMessageFactory}</code>.
*
* @p... |
return new RangeShouldBeClosedInTheLowerBound(
"%nExpecting:%n %s%nto be closed in the lower bound but was opened", actual);
| 167 | 46 | 213 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/RangeShouldBeClosedInTheUpperBound.java | RangeShouldBeClosedInTheUpperBound | shouldHaveClosedUpperBound | class RangeShouldBeClosedInTheUpperBound extends BasicErrorMessageFactory {
public static <T extends Comparable<T>> ErrorMessageFactory shouldHaveClosedUpperBound(final Range<T> actual) {<FILL_FUNCTION_BODY>}
/**
* Creates a new <code>{@link org.assertj.core.error.BasicErrorMessageFactory}</code>.
*
* @p... |
return new RangeShouldBeClosedInTheUpperBound(
"%nExpecting:%n %s%nto be closed in the upper bound but was opened", actual);
| 170 | 47 | 217 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/RangeShouldBeOpenedInTheLowerBound.java | RangeShouldBeOpenedInTheLowerBound | shouldHaveOpenedLowerBound | class RangeShouldBeOpenedInTheLowerBound extends BasicErrorMessageFactory {
public static <T extends Comparable<T>> ErrorMessageFactory shouldHaveOpenedLowerBound(final Range<T> actual) {<FILL_FUNCTION_BODY>}
/**
* Creates a new <code>{@link org.assertj.core.error.BasicErrorMessageFactory}</code>.
*
* @p... |
return new RangeShouldBeOpenedInTheLowerBound(
"%nExpecting:%n %s%nto be opened in the lower bound but was closed", actual);
| 167 | 46 | 213 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/RangeShouldBeOpenedInTheUpperBound.java | RangeShouldBeOpenedInTheUpperBound | shouldHaveOpenedUpperBound | class RangeShouldBeOpenedInTheUpperBound extends BasicErrorMessageFactory {
public static <T extends Comparable<T>> ErrorMessageFactory shouldHaveOpenedUpperBound(final Range<T> actual) {<FILL_FUNCTION_BODY>}
/**
* Creates a new <code>{@link org.assertj.core.error.BasicErrorMessageFactory}</code>.
*
* @p... |
return new RangeShouldBeOpenedInTheUpperBound(
"%nExpecting:%n %s%nto be opened in the upper bound but was closed", actual);
| 170 | 47 | 217 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/RangeShouldHaveLowerEndpointEqual.java | RangeShouldHaveLowerEndpointEqual | shouldHaveEqualLowerEndpoint | class RangeShouldHaveLowerEndpointEqual extends BasicErrorMessageFactory {
public static <T extends Comparable<T>> ErrorMessageFactory shouldHaveEqualLowerEndpoint(final Range<T> actual,
final Object value) {<FILL_FUNCTION_BOD... |
return new RangeShouldHaveLowerEndpointEqual("%n" +
"Expecting:%n" +
" %s%n" +
"to have lower endpoint equal to:%n" +
... | 167 | 97 | 264 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/RangeShouldHaveUpperEndpointEqual.java | RangeShouldHaveUpperEndpointEqual | shouldHaveEqualUpperEndpoint | class RangeShouldHaveUpperEndpointEqual extends BasicErrorMessageFactory {
public static <T extends Comparable<T>> ErrorMessageFactory shouldHaveEqualUpperEndpoint(final Range<T> actual,
final Object value) {<FILL_FUNCTION_BOD... |
return new RangeShouldHaveUpperEndpointEqual("%n" +
"Expecting:%n" +
" %s%n" +
"to have upper endpoint equal to:%n" +
... | 170 | 98 | 268 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/ShouldContainKeys.java | ShouldContainKeys | shouldContainKeys | class ShouldContainKeys extends BasicErrorMessageFactory {
private ShouldContainKeys(Object actual, Object key) {
super("%nExpecting:%n %s%nto contain key:%n %s", actual, key);
}
private ShouldContainKeys(Object actual, Object[] keys, Set<?> keysNotFound) {
super("%nExpecting:%n %s%nto contain keys:%... |
return keys.length == 1 ? new ShouldContainKeys(actual, keys[0]) : new ShouldContainKeys(actual, keys, keysNotFound);
| 255 | 38 | 293 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/ShouldContainValues.java | ShouldContainValues | shouldContainValues | class ShouldContainValues extends BasicErrorMessageFactory {
public static ErrorMessageFactory shouldContainValues(Object actual, Object[] values, Set<?> valuesNotFound) {<FILL_FUNCTION_BODY>}
private ShouldContainValues(Object actual, Object value) {
super("%nExpecting:%n %s%nto contain value:%n %s", actua... |
return values.length == 1 ? new ShouldContainValues(actual, values[0])
: new ShouldContainValues(actual, values,
valuesNotFound);
| 175 | 42 | 217 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/TableShouldContainColumns.java | TableShouldContainColumns | tableShouldContainColumns | class TableShouldContainColumns extends BasicErrorMessageFactory {
public static ErrorMessageFactory tableShouldContainColumns(Object actual, Object[] columns, Set<?> columnsNotFound) {<FILL_FUNCTION_BODY>}
private TableShouldContainColumns(Object actual, Object row) {
super("%nExpecting:%n %s%nto contain co... |
return columns.length == 1 ? new TableShouldContainColumns(actual, columns[0])
: new TableShouldContainColumns(actual, columns,
columnsNotFound);
| 179 | 44 | 223 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-guava/src/main/java/org/assertj/guava/error/TableShouldContainRows.java | TableShouldContainRows | tableShouldContainRows | class TableShouldContainRows extends BasicErrorMessageFactory {
public static ErrorMessageFactory tableShouldContainRows(Object actual, Object[] rows, Set<?> rowsNotFound) {<FILL_FUNCTION_BODY>}
private TableShouldContainRows(Object actual, Object row) {
super("%nExpecting:%n %s%nto contain row:%n %s", actu... |
return rows.length == 1 ? new TableShouldContainRows(actual, rows[0])
: new TableShouldContainRows(actual, rows,
rowsNotFound);
| 179 | 45 | 224 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/ClientStats.java | ClientStats | equals | class ClientStats {
private final Map<String, HostStats> statsPerHost;
public ClientStats(Map<String, HostStats> statsPerHost) {
this.statsPerHost = Collections.unmodifiableMap(statsPerHost);
}
/**
* @return A map from hostname to statistics on that host's connections.
* The returne... |
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final ClientStats that = (ClientStats) o;
return Objects.equals(statsPerHost, that.statsPerHost);
| 507 | 78 | 585 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/DefaultRequest.java | DefaultRequest | getQueryParams | class DefaultRequest implements Request {
public final @Nullable ProxyServer proxyServer;
private final String method;
private final Uri uri;
private final @Nullable InetAddress address;
private final @Nullable InetAddress localAddress;
private final HttpHeaders headers;
private final List<... |
// lazy load
if (queryParams == null) {
if (isNonEmpty(uri.getQuery())) {
queryParams = new ArrayList<>(1);
for (String queryStringParam : uri.getQuery().split("&")) {
int pos = queryStringParam.indexOf('=');
if (pos <=... | 1,766 | 173 | 1,939 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/Dsl.java | Dsl | realm | class Dsl {
private Dsl() {
}
// /////////// Client ////////////////
public static AsyncHttpClient asyncHttpClient() {
return new DefaultAsyncHttpClient();
}
public static AsyncHttpClient asyncHttpClient(DefaultAsyncHttpClientConfig.Builder configBuilder) {
return new DefaultA... |
return new Realm.Builder(prototype.getPrincipal(), prototype.getPassword())
.setRealmName(prototype.getRealmName())
.setAlgorithm(prototype.getAlgorithm())
.setNc(prototype.getNc())
.setNonce(prototype.getNonce())
.setCharset(proto... | 679 | 293 | 972 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/HostStats.java | HostStats | equals | class HostStats {
private final long activeConnectionCount;
private final long idleConnectionCount;
public HostStats(long activeConnectionCount, long idleConnectionCount) {
this.activeConnectionCount = activeConnectionCount;
this.idleConnectionCount = idleConnectionCount;
}
/**
... |
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final HostStats hostStats = (HostStats) o;
return activeConnectionCount == hostStats.activeConnectionCount && idleConnectionCount == hostStats.idleConne... | 366 | 87 | 453 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/Param.java | Param | map2ParamList | class Param {
private final String name;
private final @Nullable String value;
public Param(String name, @Nullable String value) {
this.name = name;
this.value = value;
}
public static @Nullable List<Param> map2ParamList(Map<String, List<String>> map) {<FILL_FUNCTION_BODY>}
p... |
if (map == null) {
return null;
}
List<Param> params = new ArrayList<>(map.size());
for (Map.Entry<String, List<String>> entries : map.entrySet()) {
String name = entries.getKey();
for (String value : entries.getValue()) {
params.add(... | 384 | 106 | 490 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/channel/DefaultKeepAliveStrategy.java | DefaultKeepAliveStrategy | keepAlive | class DefaultKeepAliveStrategy implements KeepAliveStrategy {
/**
* Implemented in accordance with RFC 7230 section 6.1 <a href="https://tools.ietf.org/html/rfc7230#section-6.1">...</a>
*/
@Override
public boolean keepAlive(InetSocketAddress remoteAddress, Request ahcRequest, HttpRequest request,... |
return HttpUtil.isKeepAlive(response) &&
HttpUtil.isKeepAlive(request) &&
// support non-standard Proxy-Connection
!response.headers().contains("Proxy-Connection", CLOSE, true);
| 123 | 60 | 183 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigHelper.java | Config | parsePropertiesFile | class Config {
public static final String DEFAULT_AHC_PROPERTIES = "ahc-default.properties";
public static final String CUSTOM_AHC_PROPERTIES = "ahc.properties";
private final ConcurrentHashMap<String, String> propsCache = new ConcurrentHashMap<>();
private final Properties defaultProp... |
Properties props = new Properties();
try (InputStream is = getClass().getResourceAsStream(file)) {
if (is != null) {
try {
props.load(is);
} catch (IOException e) {
throw new IllegalArgument... | 577 | 139 | 716 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/filter/ReleasePermitOnComplete.java | ReleasePermitOnComplete | allInterfaces | class ReleasePermitOnComplete {
private ReleasePermitOnComplete() {
// Prevent outside initialization
}
/**
* Wrap handler to release the permit of the semaphore on {@link AsyncHandler#onCompleted()}.
*
* @param handler the handler to be wrapped
* @param available the Semapho... |
Set<Class<?>> allInterfaces = new HashSet<>();
for (Class<?> clazz = handlerClass; clazz != null; clazz = clazz.getSuperclass()) {
Collections.addAll(allInterfaces, clazz.getInterfaces());
}
return allInterfaces.toArray(new Class[0]);
| 382 | 88 | 470 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/filter/ThrottleRequestFilter.java | ThrottleRequestFilter | filter | class ThrottleRequestFilter implements RequestFilter {
private static final Logger logger = LoggerFactory.getLogger(ThrottleRequestFilter.class);
private final Semaphore available;
private final int maxWait;
public ThrottleRequestFilter(int maxConnections) {
this(maxConnections, Integer.MAX_VAL... |
try {
if (logger.isDebugEnabled()) {
logger.debug("Current Throttling Status {}", available.availablePermits());
}
if (!available.tryAcquire(maxWait, TimeUnit.MILLISECONDS)) {
throw new FilterException(String.format("No slot available for proc... | 220 | 194 | 414 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/handler/BodyDeferringAsyncHandler.java | BodyDeferringInputStream | close | class BodyDeferringInputStream extends FilterInputStream {
private final Future<Response> future;
private final BodyDeferringAsyncHandler bdah;
public BodyDeferringInputStream(final Future<Response> future, final BodyDeferringAsyncHandler bdah, final InputStream in) {
super(in);
... |
// close
super.close();
// "join" async request
try {
getLastResponse();
} catch (ExecutionException e) {
throw new IOException(e.getMessage(), e.getCause());
} catch (InterruptedException e) {
throw... | 412 | 83 | 495 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/handler/TransferCompletionHandler.java | TransferCompletionHandler | fireOnHeadersSent | class TransferCompletionHandler extends AsyncCompletionHandlerBase {
private static final Logger logger = LoggerFactory.getLogger(TransferCompletionHandler.class);
private final ConcurrentLinkedQueue<TransferListener> listeners = new ConcurrentLinkedQueue<>();
private final boolean accumulateResponseBytes;... |
for (TransferListener l : listeners) {
try {
l.onRequestHeadersSent(headers);
} catch (Throwable t) {
l.onThrowable(t);
}
}
| 1,090 | 56 | 1,146 | <methods>public non-sealed void <init>() ,public org.asynchttpclient.Response onCompleted(org.asynchttpclient.Response) throws java.lang.Exception<variables> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/handler/resumable/PropertiesBasedResumableProcessor.java | PropertiesBasedResumableProcessor | load | class PropertiesBasedResumableProcessor implements ResumableAsyncHandler.ResumableProcessor {
private static final Logger log = LoggerFactory.getLogger(PropertiesBasedResumableProcessor.class);
private static final File TMP = new File(System.getProperty("java.io.tmpdir"), "ahc");
private static final String... |
Scanner scan = null;
try {
scan = new Scanner(new File(TMP, storeName), UTF_8);
scan.useDelimiter("[=\n]");
String key;
String value;
while (scan.hasNext()) {
key = scan.next().trim();
value = scan.next().trim(... | 535 | 218 | 753 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/handler/resumable/ResumableIOExceptionFilter.java | ResumableIOExceptionFilter | filter | class ResumableIOExceptionFilter implements IOExceptionFilter {
@Override
public <T> FilterContext<T> filter(FilterContext<T> ctx) {<FILL_FUNCTION_BODY>}
} |
if (ctx.getIOException() != null && ctx.getAsyncHandler() instanceof ResumableAsyncHandler) {
Request request = ((ResumableAsyncHandler) ctx.getAsyncHandler()).adjustRequestRange(ctx.getRequest());
return new FilterContext.FilterContextBuilder<>(ctx).request(request).replayRequest(true)... | 51 | 92 | 143 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/handler/resumable/ResumableRandomAccessFileListener.java | ResumableRandomAccessFileListener | length | class ResumableRandomAccessFileListener implements ResumableListener {
private final RandomAccessFile file;
public ResumableRandomAccessFileListener(RandomAccessFile file) {
this.file = file;
}
/**
* This method uses the last valid bytes written on disk to position a {@link RandomAccessFi... |
try {
return file.length();
} catch (IOException e) {
return -1;
}
| 307 | 32 | 339 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/NettyResponse.java | NettyResponse | buildCookies | class NettyResponse implements Response {
private final List<HttpResponseBodyPart> bodyParts;
private final HttpHeaders headers;
private final HttpResponseStatus status;
private List<Cookie> cookies;
public NettyResponse(HttpResponseStatus status,
HttpHeaders headers,
... |
List<String> setCookieHeaders = headers.getAll(SET_COOKIE2);
if (!isNonEmpty(setCookieHeaders)) {
setCookieHeaders = headers.getAll(SET_COOKIE);
}
if (isNonEmpty(setCookieHeaders)) {
List<Cookie> cookies = new ArrayList<>(1);
for (String value : se... | 1,194 | 177 | 1,371 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/SimpleChannelFutureListener.java | SimpleChannelFutureListener | operationComplete | class SimpleChannelFutureListener implements ChannelFutureListener {
@Override
public final void operationComplete(ChannelFuture future) {<FILL_FUNCTION_BODY>}
public abstract void onSuccess(Channel channel);
public abstract void onFailure(Channel channel, Throwable cause);
} |
Channel channel = future.channel();
if (future.isSuccess()) {
onSuccess(channel);
} else {
onFailure(channel, future.cause());
}
| 72 | 48 | 120 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/SimpleFutureListener.java | SimpleFutureListener | operationComplete | class SimpleFutureListener<V> implements FutureListener<V> {
@Override
public final void operationComplete(Future<V> future) throws Exception {<FILL_FUNCTION_BODY>}
protected abstract void onSuccess(V value) throws Exception;
protected abstract void onFailure(Throwable t) throws Exception;
} |
if (future.isSuccess()) {
onSuccess(future.getNow());
} else {
onFailure(future.cause());
}
| 82 | 40 | 122 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/channel/CombinedConnectionSemaphore.java | CombinedConnectionSemaphore | acquireChannelLock | class CombinedConnectionSemaphore extends PerHostConnectionSemaphore {
protected final MaxConnectionSemaphore globalMaxConnectionSemaphore;
CombinedConnectionSemaphore(int maxConnections, int maxConnectionsPerHost, int acquireTimeout) {
super(maxConnectionsPerHost, acquireTimeout);
globalMaxCon... |
long remainingTime = acquireTimeout > 0 ? acquireGlobalTimed(partitionKey) : acquireGlobal(partitionKey);
try {
if (remainingTime < 0 || !getFreeConnectionsForHost(partitionKey).tryAcquire(remainingTime, TimeUnit.MILLISECONDS)) {
releaseGlobal(partitionKey);
... | 356 | 125 | 481 | <methods>public void acquireChannelLock(java.lang.Object) throws java.io.IOException,public void releaseChannelLock(java.lang.Object) <variables>protected final non-sealed int acquireTimeout,protected final ConcurrentHashMap<java.lang.Object,java.util.concurrent.Semaphore> freeChannelsPerHost,protected final non-sealed... |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/channel/DefaultChannelPool.java | IdleChannelDetector | closeChannels | class IdleChannelDetector implements TimerTask {
private boolean isIdleTimeoutExpired(IdleChannel idleChannel, long now) {
return maxIdleTimeEnabled && now - idleChannel.start >= maxIdleTime;
}
private List<IdleChannel> expiredChannels(ConcurrentLinkedDeque<IdleChannel> partition, ... |
// lazy create, only if we hit a non-closeable channel
List<IdleChannel> closedChannels = null;
for (int i = 0; i < candidates.size(); i++) {
// We call takeOwnership here to avoid closing a channel that has just been taken out
// of the pool, otherwi... | 785 | 283 | 1,068 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/channel/DefaultConnectionSemaphoreFactory.java | DefaultConnectionSemaphoreFactory | newConnectionSemaphore | class DefaultConnectionSemaphoreFactory implements ConnectionSemaphoreFactory {
@Override
public ConnectionSemaphore newConnectionSemaphore(AsyncHttpClientConfig config) {<FILL_FUNCTION_BODY>}
} |
int acquireFreeChannelTimeout = Math.max(0, config.getAcquireFreeChannelTimeout());
int maxConnections = config.getMaxConnections();
int maxConnectionsPerHost = config.getMaxConnectionsPerHost();
if (maxConnections > 0 && maxConnectionsPerHost > 0) {
return new CombinedConn... | 54 | 194 | 248 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/channel/EpollTransportFactory.java | EpollTransportFactory | isAvailable | class EpollTransportFactory implements TransportFactory<EpollSocketChannel, EpollEventLoopGroup> {
static boolean isAvailable() {<FILL_FUNCTION_BODY>}
@Override
public EpollSocketChannel newChannel() {
return new EpollSocketChannel();
}
@Override
public EpollEventLoopGroup newEventLoo... |
try {
Class.forName("io.netty.channel.epoll.Epoll");
} catch (ClassNotFoundException e) {
return false;
}
return Epoll.isAvailable();
| 124 | 55 | 179 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/channel/IoUringIncubatorTransportFactory.java | IoUringIncubatorTransportFactory | isAvailable | class IoUringIncubatorTransportFactory implements TransportFactory<IOUringSocketChannel, IOUringEventLoopGroup> {
static boolean isAvailable() {<FILL_FUNCTION_BODY>}
@Override
public IOUringSocketChannel newChannel() {
return new IOUringSocketChannel();
}
@Override
public IOUringEvent... |
try {
Class.forName("io.netty.incubator.channel.uring.IOUring");
} catch (ClassNotFoundException e) {
return false;
}
return IOUring.isAvailable();
| 135 | 60 | 195 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/channel/KQueueTransportFactory.java | KQueueTransportFactory | isAvailable | class KQueueTransportFactory implements TransportFactory<KQueueSocketChannel, KQueueEventLoopGroup> {
static boolean isAvailable() {<FILL_FUNCTION_BODY>}
@Override
public KQueueSocketChannel newChannel() {
return new KQueueSocketChannel();
}
@Override
public KQueueEventLoopGroup newEv... |
try {
Class.forName("io.netty.channel.kqueue.KQueue");
} catch (ClassNotFoundException e) {
return false;
}
return KQueue.isAvailable();
| 124 | 55 | 179 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/channel/MaxConnectionSemaphore.java | MaxConnectionSemaphore | acquireChannelLock | class MaxConnectionSemaphore implements ConnectionSemaphore {
protected final Semaphore freeChannels;
protected final IOException tooManyConnections;
protected final int acquireTimeout;
MaxConnectionSemaphore(int maxConnections, int acquireTimeout) {
tooManyConnections = unknownStackTrace(new ... |
try {
if (!freeChannels.tryAcquire(acquireTimeout, TimeUnit.MILLISECONDS)) {
throw tooManyConnections;
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
| 212 | 67 | 279 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/channel/NettyChannelConnector.java | NettyChannelConnector | connect | class NettyChannelConnector {
private static final Logger LOGGER = LoggerFactory.getLogger(NettyChannelConnector.class);
private static final AtomicIntegerFieldUpdater<NettyChannelConnector> I_UPDATER = AtomicIntegerFieldUpdater
.newUpdater(NettyChannelConnector.class, "i");
private final Asy... |
final InetSocketAddress remoteAddress = remoteAddresses.get(i);
try {
asyncHandler.onTcpConnectAttempt(remoteAddress);
} catch (Exception e) {
LOGGER.error("onTcpConnectAttempt crashed", e);
connectListener.onFailure(null, e);
return;
}
... | 631 | 168 | 799 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/channel/NettyConnectListener.java | NettyConnectListener | onSuccess | class NettyConnectListener<T> {
private static final Logger LOGGER = LoggerFactory.getLogger(NettyConnectListener.class);
private final NettyRequestSender requestSender;
private final NettyResponseFuture<T> future;
private final ChannelManager channelManager;
private final ConnectionSemaphore conn... |
if (connectionSemaphore != null) {
// transfer lock from future to channel
Object partitionKeyLock = future.takePartitionKeyLock();
if (partitionKeyLock != null) {
channel.closeFuture().addListener(future -> connectionSemaphore.releaseChannelLock(partitionKe... | 694 | 650 | 1,344 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/channel/PerHostConnectionSemaphore.java | PerHostConnectionSemaphore | acquireChannelLock | class PerHostConnectionSemaphore implements ConnectionSemaphore {
protected final ConcurrentHashMap<Object, Semaphore> freeChannelsPerHost = new ConcurrentHashMap<>();
protected final int maxConnectionsPerHost;
protected final IOException tooManyConnectionsPerHost;
protected final int acquireTimeout;
... |
try {
if (!getFreeConnectionsForHost(partitionKey).tryAcquire(acquireTimeout, TimeUnit.MILLISECONDS)) {
throw tooManyConnectionsPerHost;
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
| 322 | 75 | 397 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/future/StackTraceInspector.java | StackTraceInspector | recoverOnConnectCloseException | class StackTraceInspector {
private StackTraceInspector() {
// Prevent outside initialization
}
private static boolean exceptionInMethod(Throwable t, String className, String methodName) {
try {
for (StackTraceElement element : t.getStackTrace()) {
if (element.g... |
while (true) {
if (exceptionInMethod(t, "sun.nio.ch.SocketChannelImpl", "checkConnect")) {
return true;
}
if (t.getCause() == null) {
return false;
}
t = t.getCause();
}
| 443 | 80 | 523 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/handler/AsyncHttpClientHandler.java | AsyncHttpClientHandler | exceptionCaught | class AsyncHttpClientHandler extends ChannelInboundHandlerAdapter {
protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final AsyncHttpClientConfig config;
protected final ChannelManager channelManager;
protected final NettyRequestSender requestSender;
final Interceptors... |
Throwable cause = getCause(e);
if (cause instanceof PrematureChannelClosureException || cause instanceof ClosedChannelException) {
return;
}
Channel channel = ctx.channel();
NettyResponseFuture<?> future = null;
logger.debug("Unexpected I/O exception on ch... | 992 | 497 | 1,489 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/handler/HttpHandler.java | HttpHandler | handleHttpResponse | class HttpHandler extends AsyncHttpClientHandler {
public HttpHandler(AsyncHttpClientConfig config, ChannelManager channelManager, NettyRequestSender requestSender) {
super(config, channelManager, requestSender);
}
private static boolean abortAfterHandlingStatus(AsyncHandler<?> handler, NettyRespo... |
HttpRequest httpRequest = future.getNettyRequest().getHttpRequest();
logger.debug("\n\nRequest {}\n\nResponse {}\n", httpRequest, response);
future.setKeepAlive(config.getKeepAliveStrategy().keepAlive((InetSocketAddress) channel.remoteAddress(), future.getTargetRequest(), httpRequest, response... | 985 | 207 | 1,192 | <methods>public void channelActive(ChannelHandlerContext) ,public void channelInactive(ChannelHandlerContext) throws java.lang.Exception,public void channelRead(ChannelHandlerContext, java.lang.Object) throws java.lang.Exception,public void channelReadComplete(ChannelHandlerContext) ,public void exceptionCaught(Channel... |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/handler/WebSocketHandler.java | WebSocketHandler | upgrade | class WebSocketHandler extends AsyncHttpClientHandler {
public WebSocketHandler(AsyncHttpClientConfig config, ChannelManager channelManager, NettyRequestSender requestSender) {
super(config, channelManager, requestSender);
}
private static WebSocketUpgradeHandler getWebSocketUpgradeHandler(NettyRe... |
boolean validStatus = response.status().equals(SWITCHING_PROTOCOLS);
boolean validUpgrade = response.headers().get(UPGRADE) != null;
String connection = response.headers().get(CONNECTION);
boolean validConnection = HttpHeaderValues.UPGRADE.contentEqualsIgnoreCase(connection);
fi... | 1,012 | 462 | 1,474 | <methods>public void channelActive(ChannelHandlerContext) ,public void channelInactive(ChannelHandlerContext) throws java.lang.Exception,public void channelRead(ChannelHandlerContext, java.lang.Object) throws java.lang.Exception,public void channelReadComplete(ChannelHandlerContext) ,public void exceptionCaught(Channel... |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/handler/intercept/ConnectSuccessInterceptor.java | ConnectSuccessInterceptor | exitAfterHandlingConnect | class ConnectSuccessInterceptor {
private static final Logger LOGGER = LoggerFactory.getLogger(ConnectSuccessInterceptor.class);
private final ChannelManager channelManager;
private final NettyRequestSender requestSender;
ConnectSuccessInterceptor(ChannelManager channelManager, NettyRequestSender req... |
if (future.isKeepAlive()) {
future.attachChannel(channel, true);
}
Uri requestUri = request.getUri();
LOGGER.debug("Connecting to proxy {} for scheme {}", proxyServer, requestUri.getScheme());
final Future<Channel> whenHandshaked = channelManager.updatePipelineForHt... | 153 | 214 | 367 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/handler/intercept/Continue100Interceptor.java | Continue100Interceptor | exitAfterHandling100 | class Continue100Interceptor {
private final NettyRequestSender requestSender;
Continue100Interceptor(NettyRequestSender requestSender) {
this.requestSender = requestSender;
}
public boolean exitAfterHandling100(final Channel channel, final NettyResponseFuture<?> future) {<FILL_FUNCTION_BODY>... |
future.setHeadersAlreadyWrittenOnContinue(true);
future.setDontWriteBodyBecauseExpectContinue(false);
// directly send the body
Channels.setAttribute(channel, new OnLastHttpContentCallback(future) {
@Override
public void call() {
Channels.setAttri... | 104 | 110 | 214 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/handler/intercept/Interceptors.java | Interceptors | exitAfterIntercept | class Interceptors {
private final AsyncHttpClientConfig config;
private final Unauthorized401Interceptor unauthorized401Interceptor;
private final ProxyUnauthorized407Interceptor proxyUnauthorized407Interceptor;
private final Continue100Interceptor continue100Interceptor;
private final Redirect30x... |
HttpRequest httpRequest = future.getNettyRequest().getHttpRequest();
ProxyServer proxyServer = future.getProxyServer();
int statusCode = response.status().code();
Request request = future.getCurrentRequest();
Realm realm = request.getRealm() != null ? request.getRealm() : confi... | 486 | 560 | 1,046 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/handler/intercept/ProxyUnauthorized407Interceptor.java | ProxyUnauthorized407Interceptor | exitAfterHandling407 | class ProxyUnauthorized407Interceptor {
private static final Logger LOGGER = LoggerFactory.getLogger(ProxyUnauthorized407Interceptor.class);
private final ChannelManager channelManager;
private final NettyRequestSender requestSender;
ProxyUnauthorized407Interceptor(ChannelManager channelManager, Nett... |
if (future.isAndSetInProxyAuth(true)) {
LOGGER.info("Can't handle 407 as auth was already performed");
return false;
}
Realm proxyRealm = future.getProxyRealm();
if (proxyRealm == null) {
LOGGER.debug("Can't handle 407 as there's no proxyRealm");
... | 653 | 1,358 | 2,011 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/handler/intercept/Redirect30xInterceptor.java | Redirect30xInterceptor | exitAfterHandlingRedirect | class Redirect30xInterceptor {
public static final Set<Integer> REDIRECT_STATUSES = new HashSet<>();
private static final Logger LOGGER = LoggerFactory.getLogger(Redirect30xInterceptor.class);
static {
REDIRECT_STATUSES.add(MOVED_PERMANENTLY_301);
REDIRECT_STATUSES.add(FOUND_302);
... |
if (followRedirect(config, request)) {
if (future.incrementAndGetCurrentRedirectCount() >= config.getMaxRedirects()) {
throw maxRedirectException;
} else {
// We must allow auth handling again.
future.setInAuth(false);
fu... | 554 | 1,137 | 1,691 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/handler/intercept/ResponseFiltersInterceptor.java | ResponseFiltersInterceptor | exitAfterProcessingFilters | class ResponseFiltersInterceptor {
private final AsyncHttpClientConfig config;
private final NettyRequestSender requestSender;
ResponseFiltersInterceptor(AsyncHttpClientConfig config, NettyRequestSender requestSender) {
this.config = config;
this.requestSender = requestSender;
}
@... |
FilterContext fc = new FilterContext.FilterContextBuilder(handler, future.getCurrentRequest()).responseStatus(status)
.responseHeaders(responseHeaders).build();
for (ResponseFilter asyncFilter : config.getResponseFilters()) {
try {
fc = asyncFilter.filter(f... | 170 | 208 | 378 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/handler/intercept/Unauthorized401Interceptor.java | Unauthorized401Interceptor | exitAfterHandling401 | class Unauthorized401Interceptor {
private static final Logger LOGGER = LoggerFactory.getLogger(Unauthorized401Interceptor.class);
private final ChannelManager channelManager;
private final NettyRequestSender requestSender;
Unauthorized401Interceptor(ChannelManager channelManager, NettyRequestSender ... |
if (realm == null) {
LOGGER.debug("Can't handle 401 as there's no realm");
return false;
}
if (future.isAndSetInAuth(true)) {
LOGGER.info("Can't handle 401 as auth was already performed");
return false;
}
List<String> wwwAuthHead... | 639 | 1,255 | 1,894 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/request/WriteListener.java | WriteListener | operationComplete | class WriteListener {
private static final Logger LOGGER = LoggerFactory.getLogger(WriteListener.class);
protected final NettyResponseFuture<?> future;
final ProgressAsyncHandler<?> progressAsyncHandler;
final boolean notifyHeaders;
WriteListener(NettyResponseFuture<?> future, boolean notifyHeader... |
future.touch();
// The write operation failed. If the channel was pooled, it means it got asynchronously closed.
// Let's retry a second time.
if (cause != null) {
abortOnThrowable(channel, cause);
return;
}
if (progressAsyncHandler != null) {
... | 298 | 213 | 511 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/request/WriteProgressListener.java | WriteProgressListener | operationProgressed | class WriteProgressListener extends WriteListener implements ChannelProgressiveFutureListener {
private final long expectedTotal;
private long lastProgress;
public WriteProgressListener(NettyResponseFuture<?> future, boolean notifyHeaders, long expectedTotal) {
super(future, notifyHeaders);
... |
future.touch();
if (progressAsyncHandler != null && !notifyHeaders) {
long lastLastProgress = lastProgress;
lastProgress = progress;
if (total < 0) {
total = expectedTotal;
}
if (progress != lastLastProgress) {
... | 154 | 101 | 255 | <methods><variables>private static final Logger LOGGER,protected final non-sealed NettyResponseFuture<?> future,final non-sealed boolean notifyHeaders,final non-sealed ProgressAsyncHandler<?> progressAsyncHandler |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/request/body/BodyChunkedInput.java | BodyChunkedInput | readChunk | class BodyChunkedInput implements ChunkedInput<ByteBuf> {
public static final int DEFAULT_CHUNK_SIZE = 8 * 1024;
private final Body body;
private final int chunkSize;
private final long contentLength;
private boolean endOfInput;
private long progress;
BodyChunkedInput(Body body) {
... |
if (endOfInput) {
return null;
}
ByteBuf buffer = alloc.buffer(chunkSize);
Body.BodyState state = body.transferTo(buffer);
progress += buffer.writerIndex();
switch (state) {
case STOP:
endOfInput = true;
return buf... | 341 | 153 | 494 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/request/body/BodyFileRegion.java | BodyFileRegion | transferTo | class BodyFileRegion extends AbstractReferenceCounted implements FileRegion {
private final RandomAccessBody body;
private long transferred;
BodyFileRegion(RandomAccessBody body) {
this.body = requireNonNull(body, "body");
}
@Override
public long position() {
return 0;
}
... |
long written = body.transferTo(target);
if (written > 0) {
transferred += written;
}
return written;
| 318 | 39 | 357 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/request/body/NettyBodyBody.java | NettyBodyBody | write | class NettyBodyBody implements NettyBody {
private final Body body;
private final AsyncHttpClientConfig config;
public NettyBodyBody(Body body, AsyncHttpClientConfig config) {
this.body = body;
this.config = config;
}
public Body getBody() {
return body;
}
@Overri... |
Object msg;
if (body instanceof RandomAccessBody && !ChannelManager.isSslHandlerConfigured(channel.pipeline()) && !config.isDisableZeroCopy() && getContentLength() > 0) {
msg = new BodyFileRegion((RandomAccessBody) body);
} else {
msg = new BodyChunkedInput(body);
... | 151 | 326 | 477 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/request/body/NettyDirectBody.java | NettyDirectBody | write | class NettyDirectBody implements NettyBody {
public abstract ByteBuf byteBuf();
@Override
public void write(Channel channel, NettyResponseFuture<?> future) {<FILL_FUNCTION_BODY>}
} |
throw new UnsupportedOperationException("This kind of body is supposed to be written directly");
| 59 | 23 | 82 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/request/body/NettyFileBody.java | NettyFileBody | write | class NettyFileBody implements NettyBody {
private final File file;
private final long offset;
private final long length;
private final AsyncHttpClientConfig config;
public NettyFileBody(File file, AsyncHttpClientConfig config) {
this(file, 0, file.length(), config);
}
public Nett... |
@SuppressWarnings("resource")
// netty will close the FileChannel
FileChannel fileChannel = new RandomAccessFile(file, "r").getChannel();
boolean noZeroCopy = ChannelManager.isSslHandlerConfigured(channel.pipeline()) || config.isDisableZeroCopy();
Object body = noZeroCopy ? new ... | 266 | 185 | 451 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/request/body/NettyInputStreamBody.java | NettyInputStreamBody | write | class NettyInputStreamBody implements NettyBody {
private static final Logger LOGGER = LoggerFactory.getLogger(NettyInputStreamBody.class);
private final InputStream inputStream;
private final long contentLength;
public NettyInputStreamBody(InputStream inputStream) {
this(inputStream, -1L);
... |
final InputStream is = inputStream;
if (future.isStreamConsumed()) {
if (is.markSupported()) {
is.reset();
} else {
LOGGER.warn("Stream has already been consumed and cannot be reset");
return;
}
} else {
... | 205 | 203 | 408 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/ssl/DefaultSslEngineFactory.java | DefaultSslEngineFactory | newSslEngine | class DefaultSslEngineFactory extends SslEngineFactoryBase {
private volatile SslContext sslContext;
private SslContext buildSslContext(AsyncHttpClientConfig config) throws SSLException {
if (config.getSslContext() != null) {
return config.getSslContext();
}
SslContextBuil... |
SSLEngine sslEngine = config.isDisableHttpsEndpointIdentificationAlgorithm() ?
sslContext.newEngine(ByteBufAllocator.DEFAULT) :
sslContext.newEngine(ByteBufAllocator.DEFAULT, domain(peerHost), peerPort);
configureSslEngine(sslEngine, config);
return sslEngine;
... | 605 | 89 | 694 | <methods>public non-sealed void <init>() <variables> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/ssl/JsseSslEngineFactory.java | JsseSslEngineFactory | newSslEngine | class JsseSslEngineFactory extends SslEngineFactoryBase {
private final SSLContext sslContext;
public JsseSslEngineFactory(SSLContext sslContext) {
this.sslContext = sslContext;
}
@Override
public SSLEngine newSslEngine(AsyncHttpClientConfig config, String peerHost, int peerPort) {<FILL_F... |
SSLEngine sslEngine = sslContext.createSSLEngine(domain(peerHost), peerPort);
configureSslEngine(sslEngine, config);
return sslEngine;
| 106 | 51 | 157 | <methods>public non-sealed void <init>() <variables> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/ssl/SslEngineFactoryBase.java | SslEngineFactoryBase | configureSslEngine | class SslEngineFactoryBase implements SslEngineFactory {
protected String domain(String hostname) {
int fqdnLength = hostname.length() - 1;
return hostname.charAt(fqdnLength) == '.' ? hostname.substring(0, fqdnLength) : hostname;
}
protected void configureSslEngine(SSLEngine sslEngine, Asy... |
sslEngine.setUseClientMode(true);
if (!config.isDisableHttpsEndpointIdentificationAlgorithm()) {
SSLParameters params = sslEngine.getSSLParameters();
params.setEndpointIdentificationAlgorithm("HTTPS");
sslEngine.setSSLParameters(params);
}
| 120 | 79 | 199 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/timeout/ReadTimeoutTimerTask.java | ReadTimeoutTimerTask | run | class ReadTimeoutTimerTask extends TimeoutTimerTask {
private final long readTimeout;
ReadTimeoutTimerTask(NettyResponseFuture<?> nettyResponseFuture, NettyRequestSender requestSender, TimeoutsHolder timeoutsHolder, long readTimeout) {
super(nettyResponseFuture, requestSender, timeoutsHolder);
... |
if (done.getAndSet(true) || requestSender.isClosed()) {
return;
}
if (nettyResponseFuture.isDone()) {
timeoutsHolder.cancel();
return;
}
long now = unpreciseMillisTime();
long currentReadTimeoutInstant = readTimeout + nettyResponseF... | 121 | 263 | 384 | <methods>public void clean() <variables>private static final Logger LOGGER,protected final java.util.concurrent.atomic.AtomicBoolean done,volatile NettyResponseFuture<?> nettyResponseFuture,protected final non-sealed org.asynchttpclient.netty.request.NettyRequestSender requestSender,final non-sealed org.asynchttpclient... |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/timeout/RequestTimeoutTimerTask.java | RequestTimeoutTimerTask | run | class RequestTimeoutTimerTask extends TimeoutTimerTask {
private final long requestTimeout;
RequestTimeoutTimerTask(NettyResponseFuture<?> nettyResponseFuture,
NettyRequestSender requestSender,
TimeoutsHolder timeoutsHolder,
l... |
if (done.getAndSet(true) || requestSender.isClosed()) {
return;
}
// in any case, cancel possible readTimeout sibling
timeoutsHolder.cancel();
if (nettyResponseFuture.isDone()) {
return;
}
StringBuilder sb = StringBuilderPool.DEFAULT.st... | 127 | 158 | 285 | <methods>public void clean() <variables>private static final Logger LOGGER,protected final java.util.concurrent.atomic.AtomicBoolean done,volatile NettyResponseFuture<?> nettyResponseFuture,protected final non-sealed org.asynchttpclient.netty.request.NettyRequestSender requestSender,final non-sealed org.asynchttpclient... |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/timeout/TimeoutTimerTask.java | TimeoutTimerTask | expire | class TimeoutTimerTask implements TimerTask {
private static final Logger LOGGER = LoggerFactory.getLogger(TimeoutTimerTask.class);
protected final AtomicBoolean done = new AtomicBoolean();
protected final NettyRequestSender requestSender;
final TimeoutsHolder timeoutsHolder;
volatile NettyRespons... |
LOGGER.debug("{} for {} after {} ms", message, nettyResponseFuture, time);
requestSender.abort(nettyResponseFuture.channel(), nettyResponseFuture, new TimeoutException(message));
| 385 | 54 | 439 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/netty/timeout/TimeoutsHolder.java | TimeoutsHolder | startReadTimeout | class TimeoutsHolder {
private final Timeout requestTimeout;
private final AtomicBoolean cancelled = new AtomicBoolean();
private final Timer nettyTimer;
private final NettyRequestSender requestSender;
private final long requestTimeoutMillisTime;
private final long readTimeoutValue;
private... |
if (requestTimeout == null || !requestTimeout.isExpired() && readTimeoutValue < requestTimeoutMillisTime - unpreciseMillisTime()) {
// only schedule a new readTimeout if the requestTimeout doesn't happen first
if (task == null) {
// first call triggered from outside (els... | 697 | 166 | 863 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/proxy/ProxyServer.java | Builder | build | class Builder {
private final String host;
private final int port;
private int securedPort;
private @Nullable Realm realm;
private @Nullable List<String> nonProxyHosts;
private @Nullable ProxyType proxyType;
private @Nullable Function<Request, HttpHeaders> custom... |
List<String> nonProxyHosts = this.nonProxyHosts != null ? Collections.unmodifiableList(this.nonProxyHosts) : Collections.emptyList();
ProxyType proxyType = this.proxyType != null ? this.proxyType : ProxyType.HTTP;
return new ProxyServer(host, port, securedPort, realm, nonProxyHosts,... | 419 | 101 | 520 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/request/body/generator/ByteArrayBodyGenerator.java | ByteBody | transferTo | class ByteBody implements Body {
private boolean eof;
private int lastPosition;
@Override
public long getContentLength() {
return bytes.length;
}
@Override
public BodyState transferTo(ByteBuf target) {<FILL_FUNCTION_BODY>}
@Override
... |
if (eof) {
return BodyState.STOP;
}
final int remaining = bytes.length - lastPosition;
final int initialTargetWritableBytes = target.writableBytes();
if (remaining <= initialTargetWritableBytes) {
target.writeBytes(bytes, last... | 107 | 139 | 246 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/request/body/generator/FileBodyGenerator.java | FileBodyGenerator | createBody | class FileBodyGenerator implements BodyGenerator {
private final File file;
private final long regionSeek;
private final long regionLength;
public FileBodyGenerator(File file) {
this(file, 0L, file.length());
}
public FileBodyGenerator(File file, long regionSeek, long regionLength) {
... |
throw new UnsupportedOperationException("FileBodyGenerator.createBody isn't used, Netty direclt sends the file");
| 210 | 32 | 242 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/request/body/generator/InputStreamBodyGenerator.java | InputStreamBody | transferTo | class InputStreamBody implements Body {
private final InputStream inputStream;
private final long contentLength;
private byte[] chunk;
private InputStreamBody(InputStream inputStream, long contentLength) {
this.inputStream = inputStream;
this.contentLength = con... |
// To be safe.
chunk = new byte[target.writableBytes() - 10];
int read = -1;
boolean write = false;
try {
read = inputStream.read(chunk);
} catch (IOException ex) {
LOGGER.warn("Unable to read", ex);
}... | 153 | 139 | 292 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/request/body/generator/PushBody.java | PushBody | readNextChunk | class PushBody implements Body {
private final Queue<BodyChunk> queue;
private BodyState state = BodyState.CONTINUE;
public PushBody(Queue<BodyChunk> queue) {
this.queue = queue;
}
@Override
public long getContentLength() {
return -1;
}
@Override
public BodyState ... |
BodyState res = BodyState.SUSPEND;
while (target.isWritable() && state != BodyState.STOP) {
BodyChunk nextChunk = queue.peek();
if (nextChunk == null) {
// Nothing in the queue. suspend stream if nothing was read. (reads == 0)
return res;
... | 290 | 167 | 457 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/request/body/generator/QueueBasedFeedableBodyGenerator.java | QueueBasedFeedableBodyGenerator | feed | class QueueBasedFeedableBodyGenerator<T extends Queue<BodyChunk>> implements FeedableBodyGenerator {
protected final T queue;
private FeedListener listener;
protected QueueBasedFeedableBodyGenerator(T queue) {
this.queue = queue;
}
@Override
public Body createBody() {
return n... |
boolean offered = offer(new BodyChunk(buffer, isLast));
if (offered && listener != null) {
listener.onContentAdded();
}
return offered;
| 176 | 49 | 225 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/request/body/multipart/FileLikePart.java | FileLikePart | computeContentType | class FileLikePart extends PartBase {
private static final MimetypesFileTypeMap MIME_TYPES_FILE_TYPE_MAP;
static {
try (InputStream is = FileLikePart.class.getResourceAsStream("ahc-mime.types")) {
MIME_TYPES_FILE_TYPE_MAP = new MimetypesFileTypeMap(is);
} catch (IOException e) {
... |
return contentType != null ? contentType : MIME_TYPES_FILE_TYPE_MAP.getContentType(withDefault(fileName, ""));
| 409 | 40 | 449 | <methods>public void addCustomHeader(java.lang.String, java.lang.String) ,public java.nio.charset.Charset getCharset() ,public java.lang.String getContentId() ,public java.lang.String getContentType() ,public List<org.asynchttpclient.Param> getCustomHeaders() ,public java.lang.String getDispositionType() ,public java.l... |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/request/body/multipart/MultipartBody.java | MultipartBody | transferTo | class MultipartBody implements RandomAccessBody {
private static final Logger LOGGER = LoggerFactory.getLogger(MultipartBody.class);
private final List<MultipartPart<? extends Part>> parts;
private final String contentType;
private final byte[] boundary;
private final long contentLength;
priva... |
if (done) {
return BodyState.STOP;
}
while (target.isWritable() && !done) {
MultipartPart<? extends Part> currentPart = parts.get(currentPartIndex);
currentPart.transferTo(target);
if (currentPart.getState() == MultipartState.DONE) {
... | 682 | 137 | 819 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/request/body/multipart/MultipartUtils.java | MultipartUtils | newMultipartBody | class MultipartUtils {
private MultipartUtils() {
// Prevent outside initialization
}
/**
* Creates a new multipart entity containing the given parts.
*
* @param parts the parts to include.
* @param requestHeaders the request headers
* @return a MultipartBody
... |
requireNonNull(parts, "parts");
byte[] boundary;
String contentType;
String contentTypeHeader = requestHeaders.get(CONTENT_TYPE);
if (isNonEmpty(contentTypeHeader)) {
int boundaryLocation = contentTypeHeader.indexOf("boundary=");
if (boundaryLocation !=... | 398 | 283 | 681 | <no_super_class> |
AsyncHttpClient_async-http-client | async-http-client/client/src/main/java/org/asynchttpclient/request/body/multipart/PartBase.java | PartBase | addCustomHeader | class PartBase implements Part {
/**
* The name of the form field, part of the Content-Disposition header
*/
private final String name;
/**
* The main part of the Content-Type header
*/
private final String contentType;
/**
* The charset (part of Content-Type header)
... |
if (customHeaders == null) {
customHeaders = new ArrayList<>(2);
}
customHeaders.add(new Param(name, value));
| 728 | 42 | 770 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.