Skip to content

Reload key and certs in SockerAppender reconnector #2767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2a45658
Reload key and certs in SockerAppender reconnector
MichaelMorrisEst Jul 24, 2024
580ec20
Evict old connections during reconfiguration
MichaelMorrisEst Aug 21, 2024
575f8f7
Reload key and certs in SockerAppender reconnector
MichaelMorrisEst Jul 24, 2024
1ef19d1
Evict old connections during reconfiguration
MichaelMorrisEst Aug 21, 2024
9ccac2d
Avoid caching configuration in `SslConfigurationFactory`
vy Aug 29, 2024
6e90862
Overhaul `SslConfiguration` to improve reload support
vy Aug 29, 2024
799abc4
Avoid `Thread.sleep()` in `SocketAppenderReconnectTest`
vy Aug 29, 2024
c39d865
Overhaul SSL tests
vy Aug 30, 2024
9519457
Use distinct passwords for SSL key stores in tests
vy Aug 30, 2024
0bbf3c5
Extend `SocketAppenderReconnectTest` to test key & trust store reloads
vy Sep 3, 2024
4b81792
Merge remote-tracking branch 'origin/2.x' into ssl-cfg
vy Sep 3, 2024
2060e83
Merge branch 'ssl-cfg' into nordix-log4j2-2988
vy Sep 3, 2024
c58e6d2
Minor corrections
vy Sep 3, 2024
9121978
Add changelog entry
vy Sep 3, 2024
75503e3
Fix `bnd-baseline:baseline` failures
vy Sep 3, 2024
7c81318
Merge branch '2.x' into nordix-log4j2-2988
vy Sep 3, 2024
68e8c23
Replace `Configurator.initialize()` with `LoggerContext::new`
vy Sep 6, 2024
1c2165c
Remove country from the CA certificate
vy Sep 6, 2024
132cdd9
Fix `@Version` in `o.a.l.l.core.net.ssl`
vy Sep 6, 2024
8528e89
Improve creation of the default `SSLContext`
vy Sep 6, 2024
6676e5d
Remove complicated fallback logic in `SslConfiguration`
vy Sep 6, 2024
34eb0ef
Improve changelog
vy Sep 6, 2024
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
Expand Up @@ -15,8 +15,10 @@
* limitations under the license.
*/
@Export
@Version("2.21.1")
@Version("2.25.0")
@BaselineIgnore("2.25.0")
package org.apache.logging.log4j.core.test;

import aQute.bnd.annotation.baseline.BaselineIgnore;
import org.osgi.annotation.bundle.Export;
import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,55 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.logging.log4j.core.test;
package org.apache.logging.log4j.core.appender;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.ErrorHandler;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.status.StatusData;
import org.apache.logging.log4j.util.StackLocatorUtil;

public class ListErrorHandler implements ErrorHandler {
/**
* {@link ErrorHandler} implementation buffering invocations in the form of {@link StatusData}.
*/
final class BufferingErrorHandler implements ErrorHandler {

private final List<StatusData> statusDataBuffer = Collections.synchronizedList(new ArrayList<>());

private final ArrayList<StatusData> statusData = new ArrayList<>();
BufferingErrorHandler() {}

private void addStatusData(final String msg, final Throwable t) {
synchronized (statusData) {
final StackTraceElement caller = StackLocatorUtil.getStackTraceElement(3);
final String threadName = Thread.currentThread().getName();
statusData.add(new StatusData(caller, Level.ERROR, new SimpleMessage(msg), t, threadName));
}
private void addStatusData(final String message, final Throwable throwable) {
final StackTraceElement caller = StackLocatorUtil.getStackTraceElement(3);
final String threadName = Thread.currentThread().getName();
final StatusData statusData =
new StatusData(caller, Level.ERROR, new SimpleMessage(message), throwable, threadName);
statusDataBuffer.add(statusData);
}

@Override
public void error(String msg) {
addStatusData(msg, null);
public void error(String message) {
addStatusData(message, null);
}

@Override
public void error(String msg, Throwable t) {
addStatusData(msg, t);
public void error(final String message, final Throwable throwable) {
addStatusData(message, throwable);
}

@Override
public void error(String msg, LogEvent event, Throwable t) {
addStatusData(msg, t);
public void error(final String message, final LogEvent event, final Throwable throwable) {
addStatusData(message, throwable);
}

public void clear() {
synchronized (statusData) {
statusData.clear();
}
}

public Stream<StatusData> getStatusData() {
synchronized (statusData) {
return ((List<StatusData>) statusData.clone()).stream();
}
statusDataBuffer.clear();
}

public Stream<StatusData> findStatusData(String regex) {
return getStatusData()
.filter(data -> data.getMessage().getFormattedMessage().matches(regex));
public List<StatusData> getBuffer() {
return statusDataBuffer;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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.logging.log4j.core.appender;

import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.logging.log4j.core.net.TcpSocketManager;

/**
* {@link TcpSocketManager.HostResolver} implementation always resolving to the given list of {@link #addresses}.
*/
final class FixedHostResolver extends TcpSocketManager.HostResolver {

private final List<InetSocketAddress> addresses;

private FixedHostResolver(final List<InetSocketAddress> addresses) {
this.addresses = addresses;
}

static FixedHostResolver ofServers(final LineReadingTcpServer... servers) {
final List<InetSocketAddress> addresses = Arrays.stream(servers)
.map(server -> (InetSocketAddress) server.getServerSocket().getLocalSocketAddress())
.collect(Collectors.toList());
return new FixedHostResolver(addresses);
}

@Override
public List<InetSocketAddress> resolveHost(final String ignoredHost, final int ignoredPort) {
return addresses;
}
}
Loading