Skip to content
Open
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
15 changes: 11 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ on:
branches:
- main
push:
branches-ignore:
- 'dependabot/**'
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build:
Expand All @@ -48,10 +55,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5
with:
distribution: ${{ matrix.jdk }}
java-version: ${{ matrix.java }}
Expand Down
13 changes: 13 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@
<artifactId>guava-testlib</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>jakarta.servlet</groupId>
Expand Down Expand Up @@ -244,6 +250,13 @@
<failOnWarnings>false</failOnWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<reuseForks>true</reuseForks>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.when;
import java.util.concurrent.ExecutionException;

Expand Down Expand Up @@ -166,14 +167,16 @@ private void setupGrpcService(ImagesServiceGrpc.ImagesServiceImplBase serviceImp
grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build());
blockingStub = ImagesServiceGrpc.newBlockingStub(channel);
futureStub = ImagesServiceGrpc.newFutureStub(channel);
when(mockGrpcImagesClient.getBlockingStub()).thenReturn(blockingStub);
when(mockGrpcImagesClient.getFutureStub()).thenReturn(futureStub);
lenient().when(mockGrpcImagesClient.getBlockingStub()).thenReturn(blockingStub);
lenient().when(mockGrpcImagesClient.getFutureStub()).thenReturn(futureStub);
imagesService =
new ImagesServiceImpl(
mockEnvironmentProvider, mockGrpcImagesClient, null, mockBlobstoreReference);

when(mockEnvironmentProvider.getenv(
ImagesServiceFactoryImpl.USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV))
lenient()
.when(
mockEnvironmentProvider.getenv(
ImagesServiceFactoryImpl.USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV))
.thenReturn("true");
}

Expand Down Expand Up @@ -356,8 +359,10 @@ public void loadImageData_withLegacyBlobKey_failure() throws Exception {

public void setUpGrpc(boolean useGrpc) throws Exception {
ImagesServiceImpl.setStorageForTesting(mockStorage);
when(mockEnvironmentProvider.getenv(
ImagesServiceFactoryImpl.USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV))
lenient()
.when(
mockEnvironmentProvider.getenv(
ImagesServiceFactoryImpl.USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV))
.thenReturn(Boolean.toString(useGrpc));

if (useGrpc) {
Expand All @@ -373,8 +378,8 @@ public void setUpGrpc(boolean useGrpc) throws Exception {
InProcessChannelBuilder.forName(serverName).directExecutor().build());
blockingStub = ImagesServiceGrpc.newBlockingStub(channel);
futureStub = ImagesServiceGrpc.newFutureStub(channel);
when(mockGrpcImagesClient.getBlockingStub()).thenReturn(blockingStub);
when(mockGrpcImagesClient.getFutureStub()).thenReturn(futureStub);
lenient().when(mockGrpcImagesClient.getBlockingStub()).thenReturn(blockingStub);
lenient().when(mockGrpcImagesClient.getFutureStub()).thenReturn(futureStub);

imagesService =
new ImagesServiceImpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public void setUp() throws Exception {
ApiProxy.setEnvironmentForCurrentThread(environment);

Properties props = new Properties();
props.put("mail.debug", "true");
session = Session.getInstance(props);
}

Expand Down Expand Up @@ -177,6 +176,7 @@ public void testSendMessage_unicodeBody() throws Exception {
message.setReplyTo(new InternetAddress[] {replyTo});
message.setSubject(subject);
message.setContent(stream, "text/plain; charset=utf-16");
message.setHeader("Content-Transfer-Encoding", "8bit");
MailMessage msgProto =
MailMessage.newBuilder()
.addTo(to.toString())
Expand Down Expand Up @@ -308,6 +308,7 @@ public void testSendMessage_byteAttachment() throws Exception {
multi.addBodyPart(body);
body = new MimeBodyPart();
body.setContent(fileContents, "text/plain");
body.setHeader("Content-Transfer-Encoding", "7bit");
body.setFileName(filename);
multi.addBodyPart(body);
message.setContent(multi);
Expand Down Expand Up @@ -355,19 +356,23 @@ public void testSendMessage_nestedAttachment() throws Exception {
multi.addBodyPart(body);
body = new MimeBodyPart();
body.setContent(fileContents, "text/plain");
body.setHeader("Content-Transfer-Encoding", "7bit");
body.setFileName(filenameOuter);
multi.addBodyPart(body);
MimeMultipart nested = new MimeMultipart();
body = new MimeBodyPart();
body.setContent(fileContents, "text/plain");
body.setHeader("Content-Transfer-Encoding", "7bit");
body.setFileName(filenameNested1);
nested.addBodyPart(body);
body = new MimeBodyPart();
body.setContent(fileContents, "text/plain");
body.setHeader("Content-Transfer-Encoding", "7bit");
body.setFileName(filenameNested2);
nested.addBodyPart(body);
body = new MimeBodyPart();
body.setContent(nested);
body.setHeader("Content-Transfer-Encoding", "7bit");
multi.addBodyPart(body);
message.setContent(multi);
MailMessage msgProto =
Expand Down
13 changes: 13 additions & 0 deletions api_dev/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
Expand Down Expand Up @@ -246,6 +252,13 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>2</forkCount>
</configuration>
</plugin>
</plugins>
</build>
</project>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReadWriteLock;
Expand All @@ -157,6 +158,7 @@ public abstract class LocalDatastoreService {
// "iteration 2".

private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();
private static final AtomicBoolean loggedInitInfo = new AtomicBoolean(false);

static final double DEFAULT_DEADLINE_SECONDS = 30.0;
static final double MAX_DEADLINE_SECONDS = DEFAULT_DEADLINE_SECONDS;
Expand Down Expand Up @@ -522,9 +524,15 @@ public void init(File appDirectory, Clock clock, Map<String, String> properties)

costAnalysis = new LocalDatastoreCostAnalysis(LocalCompositeIndexManager.getInstance());

logger.atInfo().log(
"Local Datastore initialized: Type: %s Storage: %s",
spannerBacked() ? "VNext" : "High Replication", noStorage ? "In-memory" : backingStore);
if (loggedInitInfo.compareAndSet(false, true)) {
logger.atInfo().log(
"Local Datastore initialized: Type: %s Storage: %s",
spannerBacked() ? "VNext" : "High Replication", noStorage ? "In-memory" : backingStore);
} else {
logger.atFine().log(
"Local Datastore initialized: Type: %s Storage: %s",
spannerBacked() ? "VNext" : "High Replication", noStorage ? "In-memory" : backingStore);
}
}

private static <T extends Enum<T>> T getEnumProperty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.ImageTypeSpecifier;
Expand All @@ -86,6 +87,7 @@
public final class LocalImagesService extends AbstractLocalRpcService {

private static final GoogleLogger log = GoogleLogger.forEnclosingClass();
private static final AtomicBoolean loggedMissingFormatsWarning = new AtomicBoolean(false);
private String hostPrefix;

/**
Expand Down Expand Up @@ -120,22 +122,24 @@ public void init(LocalServiceContext context, Map<String, String> properties) {
Thread.currentThread().setContextClassLoader(oldLoader);
}

String[] inputFormats = {"png", "jpg", "gif", "bmp", "ico", "tif", "webp"};
String[] outputFormats = {"png", "jpg", "webp"};
for (String format : inputFormats) {
if (!ImageIO.getImageReadersByFormatName(format).hasNext()) {
log.atWarning().log(
"No image reader found for format \"%s\". An ImageIO plugin must be installed to use"
+ " this format with the DevAppServer.",
format);
if (loggedMissingFormatsWarning.compareAndSet(false, true)) {
String[] inputFormats = {"png", "jpg", "gif", "bmp", "ico", "tif", "webp"};
String[] outputFormats = {"png", "jpg", "webp"};
for (String format : inputFormats) {
if (!ImageIO.getImageReadersByFormatName(format).hasNext()) {
log.atWarning().log(
"No image reader found for format \"%s\". An ImageIO plugin must be installed to use"
+ " this format with the DevAppServer.",
format);
}
}
}
for (String format : outputFormats) {
if (!ImageIO.getImageWritersByFormatName(format).hasNext()) {
log.atWarning().log(
"No image writer found for format \"%s\". An ImageIO plugin must be installed to use"
+ " this format with the DevAppServer.",
format);
for (String format : outputFormats) {
if (!ImageIO.getImageWritersByFormatName(format).hasNext()) {
log.atWarning().log(
"No image writer found for format \"%s\". An ImageIO plugin must be installed to use"
+ " this format with the DevAppServer.",
format);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

/**
* Stub implementation of the Google App Engine mail api.
* This implementation logs messages using a {@link Logger} associated with
* This implementation logs messages using a {@link java.util.logging.Logger} associated with
* this class and keeps messages that were sent in memory. If you want to
* access the list of sent messages you can get ahold of the registered
* LocalMailService instance as follows:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import java.util.Set;
import java.util.TreeMap;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
Expand Down Expand Up @@ -90,6 +91,7 @@ public class LocalSearchService extends AbstractLocalRpcService {
public static final String USE_DIRECTORY = "LocalSearchService.useDirectory";

private static final GoogleLogger log = GoogleLogger.forEnclosingClass();
private static final AtomicBoolean loggedCreatedInfo = new AtomicBoolean(false);

/** Hash function for adding query fingerprints to cursors. */
private static final HashFunction CURSOR_HASH = Hashing.murmur3_32(1729);
Expand Down Expand Up @@ -145,7 +147,11 @@ private static int decodeCursor(SearchServicePb.SearchParams params, String curs

public LocalSearchService() {
analyzer = new WordSeparatorAnalyzer();
log.atInfo().log("Local search service created");
if (loggedCreatedInfo.compareAndSet(false, true)) {
log.atInfo().log("Local search service created");
} else {
log.atFine().log("Local search service created");
}
}

// --- Local RPC service ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
/**
* Quartz {@link Job} implementation that hits a url. The url to hit, the http method to invoke,
* headers, and any data that should be sent as part of the request are all determined by the {@link
* TaskQueueAddRequest} contained in the job data. We delegate to {@link LocalURLFetchService} for
* TaskQueueAddRequest} contained in the job data. We delegate to {@link
* com.google.appengine.api.urlfetch.dev.LocalURLFetchService} for
* the actual fetching.
*
* <p>{@link #initialize(LocalServerEnvironment, Clock)} must be called before the first invocation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.util.Map;

/**
* {@local LocalUserService} creates URLs that point to {@link
* {@link LocalUserService} creates URLs that point to {@link
* LocalLoginServlet} and {@link LocalLogoutServlet} when used within
* the Development AppServer environment.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ LocalServerEnvironment configure(String devAppServerVersion, String address, int
* <p>
* Note that this provides access to the original delegate which was established by
* the {@link DevAppServer}. Though this delegate is usually available by calling
* {@Link ApiProxy#getDelegate()} the delegate can be changed by the application so
* {@link ApiProxy#getDelegate()} the delegate can be changed by the application so
* we keep this reference to the original.
*
* @param apiProxyDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void tearDown() {
* Controls the state of a capability in testing mode.
*
* @param capability the {@link Capability} to change the status of
* @param status the {@CapabilityStatus} to set for the given Capability
* @param status the {@link CapabilityStatus} to set for the given Capability
* @return {@code this} (for chaining)
*/
public LocalCapabilitiesServiceTestConfig setCapabilityStatus(Capability capability,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,15 @@ public void testDelete_multiSuccess() throws Exception {
DeleteBlobRequest requestProto =
DeleteBlobRequest.newBuilder().addBlobKey("_foo1").addBlobKey("_foo2").build();

when(delegate.makeSyncCall(any(), any(), any(), any())).thenReturn(new byte[0]);

new BlobstoreServiceImpl().delete(new BlobKey("_foo1"), new BlobKey("_foo2"));
when(delegate.makeSyncCall(
same(ApiProxy.getCurrentEnvironment()),
eq(BlobstoreServiceImpl.PACKAGE),
eq("DeleteBlob"),
eq(requestProto.toByteArray())))
.thenReturn(new byte[0]);

new BlobstoreServiceImpl().delete(new BlobKey("_foo1"), new BlobKey("_foo2"));

verify(delegate)
.makeSyncCall(
same(ApiProxy.getCurrentEnvironment()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.notNull;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -89,7 +90,7 @@ public void setUp() throws Exception {
new AsyncDatastoreServiceFactory() {
@Override
public AsyncDatastoreService getInstance(DatastoreServiceConfig config) {
when(delegate.getDatastoreServiceConfig()).thenReturn(config);
lenient().when(delegate.getDatastoreServiceConfig()).thenReturn(config);
return delegate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,6 @@ public void testPostLoad_Get_Batch_RollbackTxn() throws Exception {
datastore.get(ImmutableList.of(yar.getKey(), yarChild.getKey()));
verifyNoMoreInteractions(mock);
// postLoad callback doesn't run until we call get() on the future.
assertThat(result.get()).containsExactly(yar.getKey(), yar, yarChild.getKey(), yarChild);
doAnswer(checkContext(new PostLoadContext(txnProvider, txn, ImmutableList.of(yar, yarChild))))
.when(mock)
.postLoad(any());
Expand Down
Loading
Loading