Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -57,13 +57,9 @@ public class FunctionExpression<S> implements Expression {

private final EvaluationContext defaultContext = new StandardEvaluationContext();

private final EvaluationException readOnlyException;

public FunctionExpression(Function<S, ?> function) {
Assert.notNull(function, "'function' must not be null.");
this.function = function;
this.readOnlyException = new EvaluationException(getExpressionString(),
"FunctionExpression is a 'read only' Expression implementation");
}

@Override
Expand Down Expand Up @@ -123,60 +119,65 @@ public <T> T getValue(EvaluationContext context, @Nullable Object rootObject, @N

@Override
public Class<?> getValueType() throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public Class<?> getValueType(@Nullable Object rootObject) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public Class<?> getValueType(EvaluationContext context) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public Class<?> getValueType(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public TypeDescriptor getValueTypeDescriptor() throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public TypeDescriptor getValueTypeDescriptor(@Nullable Object rootObject) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, @Nullable Object rootObject)
throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public void setValue(EvaluationContext context, @Nullable Object value) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public void setValue(@Nullable Object rootObject, @Nullable Object value) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public void setValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Object value)
throws EvaluationException {

throw this.readOnlyException;
throw readOnlyException();
}

private EvaluationException readOnlyException() {
return new EvaluationException(getExpressionString(),
"FunctionExpression is a 'read only' Expression implementation");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,6 +47,7 @@
*
* @author Artem Bilan
* @author Gary Russell
*
* @since 5.0
*/
public class SupplierExpression<T> implements Expression {
Expand All @@ -55,13 +56,9 @@ public class SupplierExpression<T> implements Expression {

private final EvaluationContext defaultContext = new StandardEvaluationContext();

private final EvaluationException readOnlyException;

public SupplierExpression(Supplier<T> supplier) {
Assert.notNull(supplier, "'function' must not be null.");
this.supplier = supplier;
this.readOnlyException = new EvaluationException(getExpressionString(),
"SupplierExpression is a 'read only' Expression implementation");
}

@Override
Expand Down Expand Up @@ -108,58 +105,63 @@ public <C> C getValue(EvaluationContext context, Object rootObject, Class<C> des

@Override
public Class<?> getValueType() throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public Class<?> getValueType(Object rootObject) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public Class<?> getValueType(EvaluationContext context) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public Class<?> getValueType(EvaluationContext context, Object rootObject) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public TypeDescriptor getValueTypeDescriptor() throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public TypeDescriptor getValueTypeDescriptor(Object rootObject) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject)
throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public void setValue(EvaluationContext context, Object value) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public void setValue(Object rootObject, Object value) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

@Override
public void setValue(EvaluationContext context, Object rootObject, Object value) throws EvaluationException {
throw this.readOnlyException;
throw readOnlyException();
}

private EvaluationException readOnlyException() {
return new EvaluationException(getExpressionString(),
"SupplierExpression is a 'read only' Expression implementation");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -127,6 +127,7 @@ public SimpleMessageStore(int individualCapacity, int groupCapacity, LockRegistr
*/
public SimpleMessageStore(int individualCapacity, int groupCapacity, long upperBoundTimeout,
LockRegistry lockRegistry) {

super(false);
Assert.notNull(lockRegistry, "The LockRegistry cannot be null");
this.individualUpperBound = new UpperBound(individualCapacity);
Expand Down Expand Up @@ -278,13 +279,9 @@ public void addMessagesToGroup(Object groupId, Message<?>... messages) {
try {
UpperBound upperBound;
MessageGroup group = this.groupIdToMessageGroup.get(groupId);
MessagingException outOfCapacityException =
new MessagingException(getClass().getSimpleName() +
" was out of capacity (" + this.groupCapacity + ") for group '" + groupId +
"', try constructing it with a larger capacity.");
if (group == null) {
if (this.groupCapacity > 0 && messages.length > this.groupCapacity) {
throw outOfCapacityException;
throw outOfCapacityException(groupId);
}
group = getMessageGroupFactory().create(groupId);
this.groupIdToMessageGroup.put(groupId, group);
Expand All @@ -302,7 +299,7 @@ public void addMessagesToGroup(Object groupId, Message<?>... messages) {
lock.unlock();
if (!upperBound.tryAcquire(this.upperBoundTimeout)) {
unlocked = true;
throw outOfCapacityException;
throw outOfCapacityException(groupId);
}
lock.lockInterruptibly();
group.add(message);
Expand All @@ -323,6 +320,12 @@ public void addMessagesToGroup(Object groupId, Message<?>... messages) {
}
}

private MessagingException outOfCapacityException(Object groupId) {
return new MessagingException(getClass().getSimpleName() +
" was out of capacity (" + this.groupCapacity + ") for group '" + groupId +
"', try constructing it with a larger number.");
}

@Override
public void removeMessageGroup(Object groupId) {
Lock lock = this.lockRegistry.obtain(groupId);
Expand Down
Loading