Skip to content

Commit edd825e

Browse files
authored
Dropping Support for App Engine Java 7 Runtime (#153)
* Dropping support for GAE 7 * Removed GaeThreadFactory, GaeExecutorService and RevivingScheduledExecutor * Removed the deprecated FirebaseCredential API * Removing GAE java7 related APIs (GaeThreadFactory, RevivingScheduledExecutor) * Removed GaePlatform implementation * Added FirebaseScheduledExecutor * Updated documentation * Some minor nits from code reviews * Calling super method in DefaultRunLoop executor
1 parent 27eddb6 commit edd825e

22 files changed

+135
-1438
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
- [fixed] Improved error handling in FCM by mapping more server-side
44
errors to client-side error codes.
5+
- [added] `FirebaseAuth`, `'FirebaseMessaging` and `FirebaseInstanceId`
6+
interfaces now expose a set of blocking methods. Each operation has
7+
blocking an asynchronous versions.
8+
- [changed] Removed the deprecated `FirebaseCredential` interface.
9+
- [changed] Removed the deprecated `Task` interface along with the
10+
`com.google.firebase.tasks` package.
11+
- [changed] Dropped support for App Engine's Java 7 runtime. Developers
12+
are advised to use the Admin SDK with Java 8 when deploying to App
13+
Engine.
514

615
# v5.9.0
716

src/main/java/com/google/firebase/FirebaseApp.java

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import static com.google.common.base.Preconditions.checkArgument;
2020
import static com.google.common.base.Preconditions.checkNotNull;
2121
import static com.google.common.base.Preconditions.checkState;
22-
import static java.nio.charset.StandardCharsets.UTF_8;
2322

2423
import com.google.api.client.googleapis.util.Utils;
2524
import com.google.api.client.json.JsonFactory;
@@ -35,14 +34,12 @@
3534
import com.google.common.base.MoreObjects;
3635
import com.google.common.base.Strings;
3736
import com.google.common.collect.ImmutableList;
38-
import com.google.common.io.BaseEncoding;
3937
import com.google.firebase.internal.FirebaseAppStore;
38+
import com.google.firebase.internal.FirebaseScheduledExecutor;
4039
import com.google.firebase.internal.FirebaseService;
41-
import com.google.firebase.internal.GaeThreadFactory;
4240
import com.google.firebase.internal.ListenableFuture2ApiFuture;
4341
import com.google.firebase.internal.NonNull;
4442
import com.google.firebase.internal.Nullable;
45-
import com.google.firebase.internal.RevivingScheduledExecutor;
4643

4744
import java.io.FileReader;
4845
import java.io.IOException;
@@ -252,19 +249,6 @@ static void clearInstancesForTest() {
252249
}
253250
}
254251

255-
/**
256-
* Returns persistence key. Exists to support getting {@link FirebaseApp} persistence key after
257-
* the app has been deleted.
258-
*/
259-
static String getPersistenceKey(String name, FirebaseOptions options) {
260-
return BaseEncoding.base64Url().omitPadding().encode(name.getBytes(UTF_8));
261-
}
262-
263-
/** Use this key to store data per FirebaseApp. */
264-
String getPersistenceKey() {
265-
return FirebaseApp.getPersistenceKey(getName(), getOptions());
266-
}
267-
268252
private static List<String> getAllAppNames() {
269253
Set<String> allAppNames = new HashSet<>();
270254
synchronized (appsLock) {
@@ -328,10 +312,7 @@ String getProjectId() {
328312

329313
@Override
330314
public boolean equals(Object o) {
331-
if (!(o instanceof FirebaseApp)) {
332-
return false;
333-
}
334-
return name.equals(((FirebaseApp) o).getName());
315+
return o instanceof FirebaseApp && name.equals(((FirebaseApp) o).getName());
335316
}
336317

337318
@Override
@@ -394,8 +375,8 @@ private ScheduledExecutorService ensureScheduledExecutorService() {
394375
synchronized (lock) {
395376
checkNotDeleted();
396377
if (scheduledExecutor == null) {
397-
scheduledExecutor = new RevivingScheduledExecutor(threadManager.getThreadFactory(),
398-
"firebase-scheduled-worker", GaeThreadFactory.isAvailable());
378+
scheduledExecutor = new FirebaseScheduledExecutor(getThreadFactory(),
379+
"firebase-scheduled-worker");
399380
}
400381
}
401382
}
@@ -472,7 +453,7 @@ static class TokenRefresher implements CredentialsChangedListener {
472453
}
473454

474455
@Override
475-
public final synchronized void onChanged(OAuth2Credentials credentials) throws IOException {
456+
public final synchronized void onChanged(OAuth2Credentials credentials) {
476457
if (state.get() != State.STARTED) {
477458
return;
478459
}

src/main/java/com/google/firebase/ImplFirebaseTrampolines.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ public static boolean isDefaultApp(@NonNull FirebaseApp app) {
4747
return app.isDefaultApp();
4848
}
4949

50-
public static String getPersistenceKey(@NonNull FirebaseApp app) {
51-
return app.getPersistenceKey();
52-
}
53-
54-
public static String getPersistenceKey(String name, FirebaseOptions options) {
55-
return FirebaseApp.getPersistenceKey(name, options);
56-
}
57-
5850
public static <T extends FirebaseService> T getService(
5951
@NonNull FirebaseApp app, @NonNull String id, @NonNull Class<T> type) {
6052
return type.cast(app.getService(id));

src/main/java/com/google/firebase/database/connection/NettyWebSocketClient.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import static com.google.common.base.Preconditions.checkState;
66

77
import com.google.common.base.Strings;
8-
import com.google.firebase.internal.GaeThreadFactory;
9-
import com.google.firebase.internal.RevivingScheduledExecutor;
8+
import com.google.firebase.internal.FirebaseScheduledExecutor;
109
import io.netty.bootstrap.Bootstrap;
1110
import io.netty.channel.Channel;
1211
import io.netty.channel.ChannelFuture;
@@ -66,8 +65,8 @@ class NettyWebSocketClient implements WebsocketConnection.WSClient {
6665
this.uri = checkNotNull(uri, "uri must not be null");
6766
this.eventHandler = checkNotNull(eventHandler, "event handler must not be null");
6867
this.channelHandler = new WebSocketClientHandler(uri, userAgent, eventHandler);
69-
this.executorService = new RevivingScheduledExecutor(
70-
threadFactory, "firebase-websocket-worker", GaeThreadFactory.isAvailable());
68+
this.executorService = new FirebaseScheduledExecutor(threadFactory,
69+
"firebase-websocket-worker");
7170
this.group = new NioEventLoopGroup(1, this.executorService);
7271
}
7372

@@ -103,7 +102,7 @@ protected void initChannel(SocketChannel ch) {
103102
channelFuture.addListener(
104103
new ChannelFutureListener() {
105104
@Override
106-
public void operationComplete(ChannelFuture future) throws Exception {
105+
public void operationComplete(ChannelFuture future) {
107106
if (!future.isSuccess()) {
108107
eventHandler.onError(future.cause());
109108
}
@@ -169,7 +168,7 @@ public void channelInactive(ChannelHandlerContext context) {
169168
}
170169

171170
@Override
172-
public void channelRead0(ChannelHandlerContext context, Object message) throws Exception {
171+
public void channelRead0(ChannelHandlerContext context, Object message) {
173172
Channel channel = context.channel();
174173
if (message instanceof FullHttpResponse) {
175174
checkState(!handshaker.isHandshakeComplete());

src/main/java/com/google/firebase/database/core/Context.java

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,18 @@ public class Context {
3838
private static final long DEFAULT_CACHE_SIZE = 10 * 1024 * 1024;
3939

4040
protected Logger logger;
41-
protected EventTarget eventTarget;
42-
protected AuthTokenProvider authTokenProvider;
43-
protected RunLoop runLoop;
44-
protected String persistenceKey;
45-
protected List<String> loggedComponents;
46-
protected String userAgent;
47-
protected Logger.Level logLevel = Logger.Level.INFO;
48-
protected boolean persistenceEnabled;
49-
protected long cacheSize = DEFAULT_CACHE_SIZE;
50-
protected FirebaseApp firebaseApp;
51-
private PersistenceManager forcedPersistenceManager;
41+
FirebaseApp firebaseApp;
42+
43+
EventTarget eventTarget;
44+
AuthTokenProvider authTokenProvider;
45+
RunLoop runLoop;
46+
String persistenceKey;
47+
List<String> loggedComponents;
48+
Logger.Level logLevel = Logger.Level.INFO;
49+
boolean persistenceEnabled;
50+
long cacheSize = DEFAULT_CACHE_SIZE;
51+
52+
private String userAgent;
5253
private boolean frozen = false;
5354
private boolean stopped = false;
5455

@@ -78,19 +79,11 @@ public void onError(String error) {
7879

7980
private Platform getPlatform() {
8081
if (platform == null) {
81-
if (GaePlatform.isActive()) {
82-
platform = new GaePlatform(firebaseApp);
83-
} else {
84-
platform = new JvmPlatform(firebaseApp);
85-
}
82+
platform = new JvmPlatform(firebaseApp);
8683
}
8784
return platform;
8885
}
8986

90-
public boolean isFrozen() {
91-
return frozen;
92-
}
93-
9487
public boolean isStopped() {
9588
return stopped;
9689
}
@@ -137,8 +130,8 @@ void stop() {
137130
}
138131
}
139132

140-
protected void assertUnfrozen() {
141-
if (isFrozen()) {
133+
void assertUnfrozen() {
134+
if (frozen) {
142135
throw new DatabaseException(
143136
"Modifications to DatabaseConfig objects must occur before they are in use");
144137
}
@@ -168,10 +161,6 @@ public ConnectionContext getConnectionContext() {
168161
}
169162

170163
PersistenceManager getPersistenceManager(String firebaseId) {
171-
// TODO[persistence]: Create this once and store it.
172-
if (forcedPersistenceManager != null) {
173-
return forcedPersistenceManager;
174-
}
175164
if (this.persistenceEnabled) {
176165
PersistenceManager cache = platform.createPersistenceManager(this, firebaseId);
177166
if (cache == null) {
@@ -193,11 +182,6 @@ public long getPersistenceCacheSizeBytes() {
193182
return this.cacheSize;
194183
}
195184

196-
// For testing
197-
void forcePersistenceManager(PersistenceManager persistenceManager) {
198-
this.forcedPersistenceManager = persistenceManager;
199-
}
200-
201185
public EventTarget getEventTarget() {
202186
return eventTarget;
203187
}
@@ -210,14 +194,6 @@ public String getUserAgent() {
210194
return userAgent;
211195
}
212196

213-
public String getPlatformVersion() {
214-
return getPlatform().getPlatformVersion();
215-
}
216-
217-
public String getSessionPersistenceKey() {
218-
return this.persistenceKey;
219-
}
220-
221197
public AuthTokenProvider getAuthTokenProvider() {
222198
return this.authTokenProvider;
223199
}

src/main/java/com/google/firebase/database/core/GaePlatform.java

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)